Class: SyntaxTree::Imaginary
- Inherits:
-
Object
- Object
- SyntaxTree::Imaginary
- Defined in:
- lib/syntax_tree.rb
Overview
Imaginary represents an imaginary number literal.
1i
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- String
-
the value of the imaginary number literal.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ Imaginary
constructor
A new instance of Imaginary.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Imaginary
Returns a new instance of Imaginary.
7175 7176 7177 7178 7179 |
# File 'lib/syntax_tree.rb', line 7175 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7173 7174 7175 |
# File 'lib/syntax_tree.rb', line 7173 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7170 7171 7172 |
# File 'lib/syntax_tree.rb', line 7170 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the imaginary number literal
7167 7168 7169 |
# File 'lib/syntax_tree.rb', line 7167 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7181 7182 7183 |
# File 'lib/syntax_tree.rb', line 7181 def child_nodes [] end |
#format(q) ⇒ Object
7185 7186 7187 |
# File 'lib/syntax_tree.rb', line 7185 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 |
# File 'lib/syntax_tree.rb', line 7189 def pretty_print(q) q.group(2, "(", ")") do q.text("imaginary") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7200 7201 7202 7203 7204 |
# File 'lib/syntax_tree.rb', line 7200 def to_json(*opts) { type: :imaginary, value: value, loc: location, cmts: comments }.to_json( *opts ) end |