Class: SyntaxTree::RationalLiteral

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

RationalLiteral represents the use of a rational number literal.

1r

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ RationalLiteral

Returns a new instance of RationalLiteral.



7130
7131
7132
7133
7134
# File 'lib/syntax_tree/node.rb', line 7130

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



7128
7129
7130
# File 'lib/syntax_tree/node.rb', line 7128

def comments
  @comments
end

#valueObject (readonly)

String

the rational number literal



7125
7126
7127
# File 'lib/syntax_tree/node.rb', line 7125

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7136
7137
7138
# File 'lib/syntax_tree/node.rb', line 7136

def accept(visitor)
  visitor.visit_rational(self)
end

#child_nodesObject Also known as: deconstruct



7140
7141
7142
# File 'lib/syntax_tree/node.rb', line 7140

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



7146
7147
7148
# File 'lib/syntax_tree/node.rb', line 7146

def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



7150
7151
7152
# File 'lib/syntax_tree/node.rb', line 7150

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