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.



13763
13764
13765
13766
13767
# File 'lib/syntax_tree.rb', line 13763

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



13761
13762
13763
# File 'lib/syntax_tree.rb', line 13761

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



13758
13759
13760
# File 'lib/syntax_tree.rb', line 13758

def location
  @location
end

#valueObject (readonly)

String

the value of the keyword



13755
13756
13757
# File 'lib/syntax_tree.rb', line 13755

def value
  @value
end

Instance Method Details

#child_nodesObject



13769
13770
13771
# File 'lib/syntax_tree.rb', line 13769

def child_nodes
  []
end

#format(q) ⇒ Object



13773
13774
13775
# File 'lib/syntax_tree.rb', line 13773

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

#pretty_print(q) ⇒ Object



13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
# File 'lib/syntax_tree.rb', line 13777

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



13788
13789
13790
13791
13792
# File 'lib/syntax_tree.rb', line 13788

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