Class: SportDb::Parser::Lineup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#captainObject

Returns the value of attribute captain

Returns:

  • (Object)

    the current value of captain



160
161
162
# File 'lib/sportdb/parser/parse_tree-props.rb', line 160

def captain
  @captain
end

#cardsObject

Returns the value of attribute cards

Returns:

  • (Object)

    the current value of cards



160
161
162
# File 'lib/sportdb/parser/parse_tree-props.rb', line 160

def cards
  @cards
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



160
161
162
# File 'lib/sportdb/parser/parse_tree-props.rb', line 160

def name
  @name
end

#subObject

Returns the value of attribute sub

Returns:

  • (Object)

    the current value of sub



160
161
162
# File 'lib/sportdb/parser/parse_tree-props.rb', line 160

def sub
  @sub
end

Instance Method Details

#as_jsonObject



161
162
163
164
165
166
167
168
169
# File 'lib/sportdb/parser/parse_tree-props.rb', line 161

def as_json(*)
  h = { 'name'   => name.as_json }
  h['captain']   =  captain.as_json   if captain
  h['cards']     =  cards.as_json     if cards
  h['sub']       =  sub.as_json       if sub

  ## ['<Lineup>', h]
  h     ## note - return "inline" json object (not tagged array with json object)
end

#pretty_print(q) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/sportdb/parser/parse_tree-props.rb', line 171

def pretty_print( q )
  q.group( 0, '', '') do    ##  group( indent, open, close)
    q.text( name )
    q.text( ' [c]' )   if captain

    if cards
      q.text( ' ' )
      q.pp( cards )
    end

    if sub
      q.breakable   ## can become either a space or a newline
      q.pp( sub )
    end
  end
end