Class: SportDb::Parser::RoundDef

Inherits:
Struct
  • Object
show all
Defined in:
lib/sportdb/parser/parse_tree.rb

Overview

note - for now exclusive really either date OR duration

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



32
33
34
# File 'lib/sportdb/parser/parse_tree.rb', line 32

def date
  @date
end

#durationObject

Returns the value of attribute duration

Returns:

  • (Object)

    the current value of duration



32
33
34
# File 'lib/sportdb/parser/parse_tree.rb', line 32

def duration
  @duration
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



32
33
34
# File 'lib/sportdb/parser/parse_tree.rb', line 32

def name
  @name
end

Instance Method Details

#as_jsonObject



34
35
36
37
38
39
40
41
# File 'lib/sportdb/parser/parse_tree.rb', line 34

def as_json(*)
  h = { 'name' => name.as_json }

  h['date']     = date.as_json      if date
  h['duration'] = duration.as_json  if duration

  ["<RoundDef>", h]
end

#pretty_print(q) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sportdb/parser/parse_tree.rb', line 43

def pretty_print( q )
  q.group( 4, '<RoundDef ', '>' ) do
    q.text( name )
    if date
      q.text( " date=")
      q.pp( date )
    end
    if duration
      q.text( " duration=")
      q.pp( duration )
    end
  end
end