Class: SyntaxTree::AccessCtrl

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

Overview

AccessCtrl represents a call to a method visibility control, i.e., public, protected, or private.

private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AccessCtrl.



12309
12310
12311
12312
12313
# File 'lib/syntax_tree.rb', line 12309

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



12307
12308
12309
# File 'lib/syntax_tree.rb', line 12307

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



12304
12305
12306
# File 'lib/syntax_tree.rb', line 12304

def location
  @location
end

#valueObject (readonly)

Ident

the value of this expression



12301
12302
12303
# File 'lib/syntax_tree.rb', line 12301

def value
  @value
end

Instance Method Details

#child_nodesObject



12315
12316
12317
# File 'lib/syntax_tree.rb', line 12315

def child_nodes
  [value]
end

#format(q) ⇒ Object



12319
12320
12321
# File 'lib/syntax_tree.rb', line 12319

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

#pretty_print(q) ⇒ Object



12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
# File 'lib/syntax_tree.rb', line 12323

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

    q.breakable
    q.pp(value)

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

#to_json(*opts) ⇒ Object



12334
12335
12336
12337
12338
12339
12340
12341
# File 'lib/syntax_tree.rb', line 12334

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