Class: SyntaxTree::Period

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Period represents the use of the . operator. It is usually found in method calls.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ Period

Returns a new instance of Period.



6231
6232
6233
6234
6235
# File 'lib/syntax_tree/node.rb', line 6231

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



6229
6230
6231
# File 'lib/syntax_tree/node.rb', line 6229

def comments
  @comments
end

#valueObject (readonly)

String

the period



6226
6227
6228
# File 'lib/syntax_tree/node.rb', line 6226

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



6237
6238
6239
# File 'lib/syntax_tree/node.rb', line 6237

def accept(visitor)
  visitor.visit_period(self)
end

#child_nodesObject Also known as: deconstruct



6241
6242
6243
# File 'lib/syntax_tree/node.rb', line 6241

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



6247
6248
6249
# File 'lib/syntax_tree/node.rb', line 6247

def deconstruct_keys(keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



6251
6252
6253
# File 'lib/syntax_tree/node.rb', line 6251

def format(q)
  q.text(value)
end