Class: Fbtxt::Parser::DateHeader

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

Overview

note - for now exclusive really either date OR year

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



63
64
65
# File 'lib/fbtxt/parser/parse_tree.rb', line 63

def date
  @date
end

#yearObject

Returns the value of attribute year

Returns:

  • (Object)

    the current value of year



63
64
65
# File 'lib/fbtxt/parser/parse_tree.rb', line 63

def year
  @year
end

Instance Method Details

#as_jsonObject



65
66
67
68
69
70
71
# File 'lib/fbtxt/parser/parse_tree.rb', line 65

def as_json(*)
  h = {}
  h['date']   = date.as_json     if date
  h['year']   = year.as_json     if year

  ['<DateHeader>', h]
end

#pretty_print(q) ⇒ Object



74
75
76
77
78
79
# File 'lib/fbtxt/parser/parse_tree.rb', line 74

def pretty_print( q )
  q.group( 4, '<DateHeader ', '>' ) do
    q.pp( date )  if date
    q.pp( year )  if year
  end
end