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.



12925
12926
12927
12928
12929
# File 'lib/syntax_tree.rb', line 12925

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



12923
12924
12925
# File 'lib/syntax_tree.rb', line 12923

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



12920
12921
12922
# File 'lib/syntax_tree.rb', line 12920

def location
  @location
end

#valueObject (readonly)

Ident

the value of this expression



12917
12918
12919
# File 'lib/syntax_tree.rb', line 12917

def value
  @value
end

Instance Method Details

#child_nodesObject



12931
12932
12933
# File 'lib/syntax_tree.rb', line 12931

def child_nodes
  [value]
end

#format(q) ⇒ Object



12935
12936
12937
# File 'lib/syntax_tree.rb', line 12935

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

#pretty_print(q) ⇒ Object



12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
# File 'lib/syntax_tree.rb', line 12939

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



12950
12951
12952
12953
12954
# File 'lib/syntax_tree.rb', line 12950

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