sportdb-models/lib/sportdb/rsssf_reader.rb
def parse_round_header( line )

    ## todo/fix:
    ##   simplify - for now round number always required
    #      e.g. no auto-calculation supported here
    #       fail if round found w/o number/pos !!!
    #
    #  also remove knockout flag for now (set to always false for now)
    
    logger.debug "parsing round header line: >#{line}<"

    ## check for date in header first e.g. Round 36 [Jul 20]  !!
    ##   avoid "conflict" with getting "wrong" round number from date etc.
    date = find_rsssf_date!( line, start_at: @event.start_at )
    if date
      @last_date = date
    end
    
    title, pos = find_rsssf_round!( line )

    ## check if pos available; if not auto-number/calculate
    if pos.nil?
        logger.error( "  no round pos found in line >#{line}<; round pos required in rsssf; sorry" )
        fail( "round pos required in rsssf; sorry")
    end

    logger.debug "  line: >#{line}<"
        
    ## Note: dummy/placeholder start_at, end_at date
    ##  replace/patch after adding all games for round

    round_attribs = {
      title:    title,
      title2:   nil,
      knockout: false
    }

    round = Round.find_by( event_id: @event.id,
                           pos:      pos )

    if round.present?
      logger.debug "update round #{round.id}:"
    else
      logger.debug "create round:"
      round = Round.new
          
      round_attribs = round_attribs.merge( {
        event_id: @event.id,
        pos:      pos,
        ##  todo: add num e.g. num == pos for round 1, round 2, etc. - why? why not??
        start_at: Date.parse('1911-11-11'),
        end_at:   Date.parse('1911-11-11')
      })
    end

    logger.debug round_attribs.to_json
   
    round.update_attributes!( round_attribs )

    ### store list of round ids for patching start_at/end_at at the end
    @patch_round_ids << round.id
    @last_round = round     ## keep track of last seen round for matches that follow etc.
  end
def parse_round_header( line )

    ## todo/fix:
    ##   simplify - for now round number always required
    #      e.g. no auto-calculation supported here
    #       fail if round found w/o number/pos !!!
    #
    #  also remove knockout flag for now (set to always false for now)
    
    logger.debug "parsing round header line: >#{line}<"

    ## check for date in header first e.g. Round 36 [Jul 20]  !!
    ##   avoid "conflict" with getting "wrong" round number from date etc.
    date = find_rsssf_date!( line, start_at: @event.start_at )
    if date
      @last_date = date
    end
    
    title, pos = find_rsssf_round!( line )

    ## check if pos available; if not auto-number/calculate
    if pos.nil?
        logger.error( "  no round pos found in line >#{line}<; round pos required in rsssf; sorry" )
        fail( "round pos required in rsssf; sorry")
    end

    logger.debug "  line: >#{line}<"
        
    ## Note: dummy/placeholder start_at, end_at date
    ##  replace/patch after adding all games for round

    round_attribs = {
      title:    title,
      title2:   nil,
      knockout: false
    }

    round = Round.find_by( event_id: @event.id,
                           pos:      pos )

    if round.present?
      logger.debug "update round #{round.id}:"
    else
      logger.debug "create round:"
      round = Round.new
          
      round_attribs = round_attribs.merge( {
        event_id: @event.id,
        pos:      pos,
        ##  todo: add num e.g. num == pos for round 1, round 2, etc. - why? why not??
        start_at: Date.parse('1911-11-11'),
        end_at:   Date.parse('1911-11-11')
      })
    end

    logger.debug round_attribs.to_json
   
    round.update_attributes!( round_attribs )

    ### store list of round ids for patching start_at/end_at at the end
    @patch_round_ids << round.id
    @last_round = round     ## keep track of last seen round for matches that follow etc.
  end
method find_rsssf_round!