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.



7035
7036
7037
7038
7039
# File 'lib/syntax_tree/node.rb', line 7035

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



7033
7034
7035
# File 'lib/syntax_tree/node.rb', line 7033

def comments
  @comments
end

#valueObject (readonly)

String

the period



7030
7031
7032
# File 'lib/syntax_tree/node.rb', line 7030

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7041
7042
7043
# File 'lib/syntax_tree/node.rb', line 7041

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

#child_nodesObject Also known as: deconstruct



7045
7046
7047
# File 'lib/syntax_tree/node.rb', line 7045

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



7051
7052
7053
# File 'lib/syntax_tree/node.rb', line 7051

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

#format(q) ⇒ Object



7055
7056
7057
# File 'lib/syntax_tree/node.rb', line 7055

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