Class: SportDb::Parser::LineupLine

Inherits:
Struct
  • Object
show all
Defined in:
lib/sportdb/parser/parse_tree-props.rb

Overview

change :lineup to :lineups (e.g. requires array of lineups)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#coachObject

Returns the value of attribute coach

Returns:

  • (Object)

    the current value of coach



125
126
127
# File 'lib/sportdb/parser/parse_tree-props.rb', line 125

def coach
  @coach
end

#lineupObject

Returns the value of attribute lineup

Returns:

  • (Object)

    the current value of lineup



125
126
127
# File 'lib/sportdb/parser/parse_tree-props.rb', line 125

def lineup
  @lineup
end

#teamObject

Returns the value of attribute team

Returns:

  • (Object)

    the current value of team



125
126
127
# File 'lib/sportdb/parser/parse_tree-props.rb', line 125

def team
  @team
end

Instance Method Details

#as_jsonObject



126
127
128
129
130
131
132
133
# File 'lib/sportdb/parser/parse_tree-props.rb', line 126

def as_json(*)
  h = { 'team'    => team.as_json,
        'lineups' => lineup.as_json
      }
  h['coach']  =  coach.as_json               if coach

  ['<LineupLine>', h]
end

#pretty_print(q) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/sportdb/parser/parse_tree-props.rb', line 135

def pretty_print( q )
  q.group( 4, '<LineupLine ', '>') do
    q.text( team )
    q.text( ' ' )

    ##  todo/fix - check for   "flat" items - no formation
    ##                           or empty lineup (possible?)
    ## add formation e.g. (1-) 3-4-2-1
    formation = lineup.map { |item| item.size }
    ## note - remove first entry (assume it's 1 for goalee!)
    formation.shift
    q.text( formation.join('-'))
    q.text( ' ')

    q.pp( lineup )

    if coach
      q.breakable
      q.text( "coach=" + coach )
    end
  end
end