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.
5941 5942 5943 5944 5945 |
# File 'lib/syntax_tree.rb', line 5941 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
5939 5940 5941 |
# File 'lib/syntax_tree.rb', line 5939 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
5936 5937 5938 |
# File 'lib/syntax_tree.rb', line 5936 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the floating point number literal
5933 5934 5935 |
# File 'lib/syntax_tree.rb', line 5933 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
5947 5948 5949 |
# File 'lib/syntax_tree.rb', line 5947 def child_nodes [] end |
#format(q) ⇒ Object
5951 5952 5953 |
# File 'lib/syntax_tree.rb', line 5951 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 |
# File 'lib/syntax_tree.rb', line 5955 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
5966 5967 5968 5969 5970 |
# File 'lib/syntax_tree.rb', line 5966 def to_json(*opts) { type: :float, value: value, loc: location, cmts: comments }.to_json( *opts ) end |