Class: Fbtxt::Parser::Goal

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

Overview

change/rename Goal to GoalScorer - why? why not?

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



114
115
116
# File 'lib/fbtxt/parser/parse_tree-match.rb', line 114

def count
  @count
end

#minutesObject

Returns the value of attribute minutes

Returns:

  • (Object)

    the current value of minutes



114
115
116
# File 'lib/fbtxt/parser/parse_tree-match.rb', line 114

def minutes
  @minutes
end

#playerObject

Returns the value of attribute player

Returns:

  • (Object)

    the current value of player



114
115
116
# File 'lib/fbtxt/parser/parse_tree-match.rb', line 114

def player
  @player
end

Instance Method Details

#as_jsonObject



116
117
118
119
120
121
122
123
124
# File 'lib/fbtxt/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/fbtxt/parser/parse_tree-match.rb', line 143

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

#to_sObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/fbtxt/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