Class: Fbtxt::Parser::LineupLine

Inherits:
Struct
  • Object
show all
Defined in:
lib/fbtxt/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



149
150
151
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 149

def coach
  @coach
end

#formationObject

Returns the value of attribute formation

Returns:

  • (Object)

    the current value of formation



149
150
151
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 149

def formation
  @formation
end

#lineupObject

Returns the value of attribute lineup

Returns:

  • (Object)

    the current value of lineup



149
150
151
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 149

def lineup
  @lineup
end

#teamObject

Returns the value of attribute team

Returns:

  • (Object)

    the current value of team



149
150
151
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 149

def team
  @team
end

Instance Method Details

#as_jsonObject



150
151
152
153
154
155
156
157
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 150

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



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 159

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

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

    q.pp( lineup )

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