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.



6874
6875
6876
6877
6878
# File 'lib/syntax_tree/node.rb', line 6874

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



6872
6873
6874
# File 'lib/syntax_tree/node.rb', line 6872

def comments
  @comments
end

#valueObject (readonly)

String

the period



6869
6870
6871
# File 'lib/syntax_tree/node.rb', line 6869

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



6880
6881
6882
# File 'lib/syntax_tree/node.rb', line 6880

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

#child_nodesObject Also known as: deconstruct



6884
6885
6886
# File 'lib/syntax_tree/node.rb', line 6884

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



6890
6891
6892
# File 'lib/syntax_tree/node.rb', line 6890

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

#format(q) ⇒ Object



6894
6895
6896
# File 'lib/syntax_tree/node.rb', line 6894

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