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

#construct_keys, #pretty_print, #to_json

Constructor Details

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

Returns a new instance of Period.



6996
6997
6998
6999
7000
# File 'lib/syntax_tree/node.rb', line 6996

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



6994
6995
6996
# File 'lib/syntax_tree/node.rb', line 6994

def comments
  @comments
end

#valueObject (readonly)

String

the period



6991
6992
6993
# File 'lib/syntax_tree/node.rb', line 6991

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7002
7003
7004
# File 'lib/syntax_tree/node.rb', line 7002

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

#child_nodesObject Also known as: deconstruct



7006
7007
7008
# File 'lib/syntax_tree/node.rb', line 7006

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



7012
7013
7014
# File 'lib/syntax_tree/node.rb', line 7012

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

#format(q) ⇒ Object



7016
7017
7018
# File 'lib/syntax_tree/node.rb', line 7016

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