Class: SyntaxTree::ZSuper

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

Overview

ZSuper represents the bare super keyword with no arguments.

super

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ZSuper.



13672
13673
13674
13675
13676
# File 'lib/syntax_tree.rb', line 13672

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



13670
13671
13672
# File 'lib/syntax_tree.rb', line 13670

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



13667
13668
13669
# File 'lib/syntax_tree.rb', line 13667

def location
  @location
end

#valueObject (readonly)

String

the value of the keyword



13664
13665
13666
# File 'lib/syntax_tree.rb', line 13664

def value
  @value
end

Instance Method Details

#child_nodesObject



13678
13679
13680
# File 'lib/syntax_tree.rb', line 13678

def child_nodes
  []
end

#format(q) ⇒ Object



13682
13683
13684
# File 'lib/syntax_tree.rb', line 13682

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

#pretty_print(q) ⇒ Object



13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
# File 'lib/syntax_tree.rb', line 13686

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

    q.breakable
    q.pp(value)

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

#to_json(*opts) ⇒ Object



13697
13698
13699
13700
13701
# File 'lib/syntax_tree.rb', line 13697

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