Class: Fbtxt::Parser::Penalty

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

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



88
89
90
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 88

def name
  @name
end

#noteObject

Returns the value of attribute note

Returns:

  • (Object)

    the current value of note



88
89
90
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 88

def note
  @note
end

#scoreObject

Returns the value of attribute score

Returns:

  • (Object)

    the current value of score



88
89
90
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 88

def score
  @score
end

Instance Method Details

#as_jsonObject



89
90
91
92
93
94
95
96
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 89

def as_json(*)
 h = { 'name' => name }
 h['score'] =  "#{score[0]}-#{score[1]}"   if score
 h['note']  =  "(#{note})"                 if note

 ## ['<Penalty>', h]
 h   # note - return "inline" json object
end

#pretty_print(q) ⇒ Object



107
108
109
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 107

def pretty_print( q )
  q.text( to_s )
end

#to_sObject



98
99
100
101
102
103
104
# File 'lib/fbtxt/parser/parse_tree-props.rb', line 98

def to_s
  buf = String.new
  buf << "#{score[0]}-#{score[1]} "   if score
  buf <<  name
  buf << " (#{note})"    if note
  buf
end