Class: SyntaxTree::FloatLiteral
- Inherits:
-
Object
- Object
- SyntaxTree::FloatLiteral
- Defined in:
- lib/syntax_tree.rb
Overview
FloatLiteral represents a floating point number literal.
1.0
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 floating point number literal.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ FloatLiteral
constructor
A new instance of FloatLiteral.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ FloatLiteral
Returns a new instance of FloatLiteral.
5626 5627 5628 5629 5630 |
# File 'lib/syntax_tree.rb', line 5626 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
5624 5625 5626 |
# File 'lib/syntax_tree.rb', line 5624 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
5621 5622 5623 |
# File 'lib/syntax_tree.rb', line 5621 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the floating point number literal
5618 5619 5620 |
# File 'lib/syntax_tree.rb', line 5618 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
5632 5633 5634 |
# File 'lib/syntax_tree.rb', line 5632 def child_nodes [] end |
#format(q) ⇒ Object
5636 5637 5638 |
# File 'lib/syntax_tree.rb', line 5636 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 |
# File 'lib/syntax_tree.rb', line 5640 def pretty_print(q) q.group(2, "(", ")") do q.text("float") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
5651 5652 5653 5654 5655 |
# File 'lib/syntax_tree.rb', line 5651 def to_json(*opts) { type: :float, value: value, loc: location, cmts: comments }.to_json( *opts ) end |