Class: SyntaxTree::Super
Overview
Super represents using the super keyword with arguments. It can optionally use parentheses.
super(value)
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- ArgParen | Args
-
the arguments to the keyword.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:, comments: []) ⇒ Super
constructor
A new instance of Super.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Super
Returns a new instance of Super.
9849 9850 9851 9852 9853 |
# File 'lib/syntax_tree/node.rb', line 9849 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- ArgParen | Args
-
the arguments to the keyword
9841 9842 9843 |
# File 'lib/syntax_tree/node.rb', line 9841 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9847 9848 9849 |
# File 'lib/syntax_tree/node.rb', line 9847 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
9844 9845 9846 |
# File 'lib/syntax_tree/node.rb', line 9844 def location @location end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
9855 9856 9857 |
# File 'lib/syntax_tree/node.rb', line 9855 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
9861 9862 9863 |
# File 'lib/syntax_tree/node.rb', line 9861 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 |
# File 'lib/syntax_tree/node.rb', line 9865 def format(q) q.group do q.text("super") if arguments.is_a?(ArgParen) q.format(arguments) else q.text(" ") q.nest("super ".length) { q.format(arguments) } end end end |
#pretty_print(q) ⇒ Object
9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 |
# File 'lib/syntax_tree/node.rb', line 9878 def pretty_print(q) q.group(2, "(", ")") do q.text("super") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
9889 9890 9891 9892 9893 |
# File 'lib/syntax_tree/node.rb', line 9889 def to_json(*opts) { type: :super, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |