Sha256: 41268c39167ddacc6031648290603fa519dd65082662c9007504197758e2bfd7

Contents?: true

Size: 1.69 KB

Versions: 60

Compression:

Stored size: 1.69 KB

Contents

# encoding: utf-8

module SportDb
  module FixtureHelpers

  def is_group_def?( line )
    # NB: check after is_round? (round may contain group reference!)
    ## must include bar (|) marker (make required)
    line =~ /\|/ && is_group?( line )
  end

  def is_group?( line )
    # NB: check after is_round? (round may contain group reference!)
    ## note: =~ return nil if not match found, and 0,1, etc for match
    (line =~ SportDb.lang.regex_group) != nil
  end

  def find_group_title_and_pos!( line )
    ## group pos - for now support single digit e.g 1,2,3 or letter e.g. A,B,C or HEX
    ## nb:  (?:)  = is for non-capturing group(ing)

    ## fix:
    ##   get Group|Gruppe|Grupo from lang!!!! do NOT hardcode in place

    ## todo:
    ##   check if Group A:  or [Group A]  works e.g. : or ] get matched by \b ???
    regex = /(?:Group|Gruppe|Grupo)\s+((?:\d{1}|[A-Z]{1,3}))\b/

    match = regex.match( line )
    
    return [nil,nil] if match.nil?

    pos = case match[1]
          when 'A' then 1
          when 'B' then 2
          when 'C' then 3
          when 'D' then 4
          when 'E' then 5
          when 'F' then 6
          when 'G' then 7
          when 'H' then 8
          when 'I' then 9
          when 'J' then 10
          when 'K' then 11
          when 'L' then 12
          when 'HEX' then 666    # HEX for Hexagonal - todo/check: map to something else ??
          else  match[1].to_i
          end

    title = match[0]

    logger.debug "   title: >#{title}<"
    logger.debug "   pos: >#{pos}<"
      
    line.sub!( regex, '[GROUP.TITLE+POS]' )

    return [title,pos]
  end



  end # module FixtureHelpers
end # module SportDb

Version data entries

60 entries across 60 versions & 2 rubygems

Version Path
sportdb-1.9.0 lib/sportdb/utils_group.rb
sportdb-1.8.29 lib/sportdb/utils_group.rb
sportdb-1.8.28 lib/sportdb/utils_group.rb
sportdb-1.8.27 lib/sportdb/utils_group.rb
sportdb-1.8.26 lib/sportdb/utils_group.rb
sportdb-1.8.25 lib/sportdb/utils_group.rb
sportdb-1.8.24 lib/sportdb/utils_group.rb
sportdb-1.8.23 lib/sportdb/utils_group.rb
sportdb-1.8.22 lib/sportdb/utils_group.rb
sportdb-1.8.21 lib/sportdb/utils_group.rb
sportdb-1.8.20 lib/sportdb/utils_group.rb
sportdb-1.8.19 lib/sportdb/utils_group.rb
sportdb-1.8.18 lib/sportdb/utils_group.rb
sportdb-1.8.17 lib/sportdb/utils_group.rb
sportdb-1.8.16 lib/sportdb/utils_group.rb
sportdb-1.8.15 lib/sportdb/utils_group.rb
sportdb-1.8.14 lib/sportdb/utils_group.rb
sportdb-1.8.13 lib/sportdb/utils_group.rb
sportdb-1.8.12 lib/sportdb/utils_group.rb
sportdb-1.8.11 lib/sportdb/utils_group.rb