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.
9767 9768 9769 9770 9771 |
# File 'lib/syntax_tree.rb', line 9767 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
9765 9766 9767 |
# File 'lib/syntax_tree.rb', line 9765 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
9762 9763 9764 |
# File 'lib/syntax_tree.rb', line 9762 def location @location end |
#value ⇒ Object (readonly)
- String
-
the rational number literal
9759 9760 9761 |
# File 'lib/syntax_tree.rb', line 9759 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
9773 9774 9775 |
# File 'lib/syntax_tree.rb', line 9773 def child_nodes [] end |
#format(q) ⇒ Object
9777 9778 9779 |
# File 'lib/syntax_tree.rb', line 9777 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 |
# File 'lib/syntax_tree.rb', line 9781 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
9792 9793 9794 9795 9796 |
# File 'lib/syntax_tree.rb', line 9792 def to_json(*opts) { type: :rational, value: value, loc: location, cmts: comments }.to_json( *opts ) end |