Class: SyntaxTree::Yield
Overview
Yield represents using the yield keyword with arguments.
yield value
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- Args | Paren
-
the arguments passed to the yield.
-
#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: []) ⇒ Yield
constructor
A new instance of Yield.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Yield
Returns a new instance of Yield.
11824 11825 11826 11827 11828 |
# File 'lib/syntax_tree/node.rb', line 11824 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args | Paren
-
the arguments passed to the yield
11816 11817 11818 |
# File 'lib/syntax_tree/node.rb', line 11816 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11822 11823 11824 |
# File 'lib/syntax_tree/node.rb', line 11822 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11819 11820 11821 |
# File 'lib/syntax_tree/node.rb', line 11819 def location @location end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
11830 11831 11832 |
# File 'lib/syntax_tree/node.rb', line 11830 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
11836 11837 11838 |
# File 'lib/syntax_tree/node.rb', line 11836 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 |
# File 'lib/syntax_tree/node.rb', line 11840 def format(q) q.group do q.text("yield") if arguments.is_a?(Paren) q.format(arguments) else q.if_break { q.text("(") }.if_flat { q.text(" ") } q.indent do q.breakable("") q.format(arguments) end q.breakable("") q.if_break { q.text(")") } end end end |
#pretty_print(q) ⇒ Object
11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 |
# File 'lib/syntax_tree/node.rb', line 11858 def pretty_print(q) q.group(2, "(", ")") do q.text("yield") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
11869 11870 11871 11872 11873 |
# File 'lib/syntax_tree/node.rb', line 11869 def to_json(*opts) { type: :yield, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |