Class: SyntaxTree::Period
Overview
Period represents the use of the . operator. It is usually found in method calls.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the period.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ Period
constructor
A new instance of Period.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Period
Returns a new instance of Period.
7852 7853 7854 7855 7856 |
# File 'lib/syntax_tree/node.rb', line 7852 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
7850 7851 7852 |
# File 'lib/syntax_tree/node.rb', line 7850 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the period
7847 7848 7849 |
# File 'lib/syntax_tree/node.rb', line 7847 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
7858 7859 7860 |
# File 'lib/syntax_tree/node.rb', line 7858 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
7864 7865 7866 |
# File 'lib/syntax_tree/node.rb', line 7864 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
7868 7869 7870 |
# File 'lib/syntax_tree/node.rb', line 7868 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 |
# File 'lib/syntax_tree/node.rb', line 7872 def pretty_print(q) q.group(2, "(", ")") do q.text("period") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7883 7884 7885 7886 7887 |
# File 'lib/syntax_tree/node.rb', line 7883 def to_json(*opts) { type: :period, value: value, loc: location, cmts: comments }.to_json( *opts ) end |