Class: SportDb::Parser::Penalty

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

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



64
65
66
# File 'lib/sportdb/parser/parse_tree-props.rb', line 64

def name
  @name
end

#noteObject

Returns the value of attribute note

Returns:

  • (Object)

    the current value of note



64
65
66
# File 'lib/sportdb/parser/parse_tree-props.rb', line 64

def note
  @note
end

#scoreObject

Returns the value of attribute score

Returns:

  • (Object)

    the current value of score



64
65
66
# File 'lib/sportdb/parser/parse_tree-props.rb', line 64

def score
  @score
end

Instance Method Details

#as_jsonObject



65
66
67
68
69
70
71
72
# File 'lib/sportdb/parser/parse_tree-props.rb', line 65

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



83
84
85
# File 'lib/sportdb/parser/parse_tree-props.rb', line 83

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

#to_sObject



74
75
76
77
78
79
80
# File 'lib/sportdb/parser/parse_tree-props.rb', line 74

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