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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- String
-
the period.
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.
8134 8135 8136 8137 8138 |
# File 'lib/syntax_tree/node.rb', line 8134 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
8132 8133 8134 |
# File 'lib/syntax_tree/node.rb', line 8132 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
8129 8130 8131 |
# File 'lib/syntax_tree/node.rb', line 8129 def location @location end |
#value ⇒ Object (readonly)
- String
-
the period
8126 8127 8128 |
# File 'lib/syntax_tree/node.rb', line 8126 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
8140 8141 8142 |
# File 'lib/syntax_tree/node.rb', line 8140 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
8146 8147 8148 |
# File 'lib/syntax_tree/node.rb', line 8146 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8150 8151 8152 |
# File 'lib/syntax_tree/node.rb', line 8150 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 |
# File 'lib/syntax_tree/node.rb', line 8154 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
8165 8166 8167 8168 8169 |
# File 'lib/syntax_tree/node.rb', line 8165 def to_json(*opts) { type: :period, value: value, loc: location, cmts: comments }.to_json( *opts ) end |