Class: SportDb::Parser::Goal
- Defined in:
- lib/sportdb/parser/parse_tree-match.rb
Overview
change/rename Goal to GoalScorer - why? why not?
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#minutes ⇒ Object
Returns the value of attribute minutes.
-
#player ⇒ Object
Returns the value of attribute player.
Instance Method Summary collapse
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count
114 115 116 |
# File 'lib/sportdb/parser/parse_tree-match.rb', line 114 def count @count end |
#minutes ⇒ Object
Returns the value of attribute minutes
114 115 116 |
# File 'lib/sportdb/parser/parse_tree-match.rb', line 114 def minutes @minutes end |
#player ⇒ Object
Returns the value of attribute player
114 115 116 |
# File 'lib/sportdb/parser/parse_tree-match.rb', line 114 def player @player end |
Instance Method Details
#as_json ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/sportdb/parser/parse_tree-match.rb', line 116 def as_json(*) h = { 'player' => player.as_json } h['count'] = count.as_json if count h['minutes'] = minutes.as_json if minutes && !minutes.empty? ## ['<Goal>', h] h # note - return "inline" json object end |
#pretty_print(q) ⇒ Object
143 144 145 |
# File 'lib/sportdb/parser/parse_tree-match.rb', line 143 def pretty_print( q ) q.text( to_s ) end |
#to_s ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/sportdb/parser/parse_tree-match.rb', line 127 def to_s buf = String.new buf << "#{player}" if count buf << (" " + count.inspect + ",") else if minutes.nil? || minutes.empty? ## add nothing if no minutes available/present else buf << " " buf << minutes.map { |min| min.to_s }.join(' ') end end buf end |