Class: SyntaxTree::RationalLiteral
- Inherits:
-
Object
- Object
- SyntaxTree::RationalLiteral
- Defined in:
- lib/syntax_tree.rb
Overview
RationalLiteral represents the use of a rational number literal.
1r
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 rational number literal.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ RationalLiteral
constructor
A new instance of RationalLiteral.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ RationalLiteral
Returns a new instance of RationalLiteral.
9691 9692 9693 9694 9695 |
# File 'lib/syntax_tree.rb', line 9691 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
9689 9690 9691 |
# File 'lib/syntax_tree.rb', line 9689 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
9686 9687 9688 |
# File 'lib/syntax_tree.rb', line 9686 def location @location end |
#value ⇒ Object (readonly)
- String
-
the rational number literal
9683 9684 9685 |
# File 'lib/syntax_tree.rb', line 9683 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
9697 9698 9699 |
# File 'lib/syntax_tree.rb', line 9697 def child_nodes [] end |
#format(q) ⇒ Object
9701 9702 9703 |
# File 'lib/syntax_tree.rb', line 9701 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 |
# File 'lib/syntax_tree.rb', line 9705 def pretty_print(q) q.group(2, "(", ")") do q.text("rational") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
9716 9717 9718 9719 9720 |
# File 'lib/syntax_tree.rb', line 9716 def to_json(*opts) { type: :rational, value: value, loc: location, cmts: comments }.to_json( *opts ) end |