Class: SyntaxTree::JSON::LiteralNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/syntax_tree/json.rb

Overview

This contains a literal node. The value argument to the struct is a literal value like a string, number, or boolean.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



85
86
87
# File 'lib/syntax_tree/json.rb', line 85

def value
  @value
end

Instance Method Details

#format(q) ⇒ Object



86
87
88
# File 'lib/syntax_tree/json.rb', line 86

def format(q)
  q.text(value.to_json)
end

#pretty_print(q) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/syntax_tree/json.rb', line 90

def pretty_print(q)
  q.group(2, "(literal", ")") do
    q.breakable
    q.text("value=")
    q.text(value.inspect)
  end
end