Class: Fbtxt::Parser::Lineup

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



189
190
191
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 189

def captain
  @captain
end

#cardsObject

Returns the value of attribute cards

Returns:

  • (Object)

    the current value of cards



189
190
191
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 189

def cards
  @cards
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



189
190
191
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 189

def name
  @name
end

#subObject

Returns the value of attribute sub

Returns:

  • (Object)

    the current value of sub



189
190
191
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 189

def sub
  @sub
end

Instance Method Details

#as_jsonObject



190
191
192
193
194
195
196
197
198
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 190

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



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 200

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