Class: SyntaxTree::VCall

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

Overview

VCall represent any plain named object with Ruby that could be either a local variable or a method call.

variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of VCall.



12844
12845
12846
12847
12848
# File 'lib/syntax_tree.rb', line 12844

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



12842
12843
12844
# File 'lib/syntax_tree.rb', line 12842

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



12839
12840
12841
# File 'lib/syntax_tree.rb', line 12839

def location
  @location
end

#valueObject (readonly)

Ident

the value of this expression



12836
12837
12838
# File 'lib/syntax_tree.rb', line 12836

def value
  @value
end

Instance Method Details

#child_nodesObject



12850
12851
12852
# File 'lib/syntax_tree.rb', line 12850

def child_nodes
  [value]
end

#format(q) ⇒ Object



12854
12855
12856
# File 'lib/syntax_tree.rb', line 12854

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

#pretty_print(q) ⇒ Object



12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
# File 'lib/syntax_tree.rb', line 12858

def pretty_print(q)
  q.group(2, "(", ")") do
    q.text("vcall")

    q.breakable
    q.pp(value)

    q.pp(Comment::List.new(comments))
  end
end

#to_json(*opts) ⇒ Object



12869
12870
12871
12872
12873
# File 'lib/syntax_tree.rb', line 12869

def to_json(*opts)
  { type: :vcall, value: value, loc: location, cmts: comments }.to_json(
    *opts
  )
end