Class: Yoda::AST::MultipleLeftHandSideNode
- Defined in:
- lib/yoda/ast/multiple_left_hand_side_node.rb
Instance Attribute Summary
Attributes inherited from Node
Attributes inherited from Vnode
Instance Method Summary collapse
- #parameter ⇒ Model::Parameters::Base
- #post_nodes ⇒ Array<Vnode>
- #pre_nodes ⇒ Array<Vnode>
- #rest_node ⇒ Vnode?
Methods inherited from Node
#children, #identifier, #initialize, #kind, #source_map
Methods inherited from Vnode
#children, #constant?, #empty?, #identifier, #initialize, #inspect, #inspect_content, #nesting, #present?, #try, #type, #wrap_child
Methods included from Vnode::CommentPositional
#comments_by_vnode, #positionally_nearest_comment, #positionally_nearest_commenting_node
Methods included from Vnode::Positional
#location, #positionally_include?, #positionally_nearest_child, #range, #source_map
Methods included from Vnode::CommentAssociation
#all_nodes_lazy, #associate_comments, #comments, #wrapping?
Methods included from Traversable
#query, #query_all, #query_ancestor, #query_ancestors
Methods included from MethodTraversable
#calc_current_location_method, #including_method, #method?
Methods included from NamespaceTraversable
#calc_current_location_namespace, #full_name, #namespace, #namespace?, #namespace_path, #root?
Constructor Details
This class inherits a constructor from Yoda::AST::Node
Instance Method Details
#parameter ⇒ Model::Parameters::Base
20 21 22 23 24 25 26 27 28 |
# File 'lib/yoda/ast/multiple_left_hand_side_node.rb', line 20 def parameter rest_parameter = rest_node&.respond_to?(:parameter) && rest_node.parameter Model::Parameters::Multiple.new( parameters: pre_nodes.map(&:parameter), rest_parameter: rest_parameter, post_parameters: post_nodes.map(&:paramter), ) end |
#post_nodes ⇒ Array<Vnode>
15 16 17 |
# File 'lib/yoda/ast/multiple_left_hand_side_node.rb', line 15 def post_nodes @post_nodes ||= children.drop_while { |arg_node| %i(arg optarg mlhs).include?(arg_node.type) }.select { |arg_node| %i(arg optarg mlhs).include?(arg_node.type) } end |
#pre_nodes ⇒ Array<Vnode>
5 6 7 |
# File 'lib/yoda/ast/multiple_left_hand_side_node.rb', line 5 def pre_nodes @pre_nodes ||= children.take_while { |arg_node| %i(arg optarg mlhs).include?(arg_node.type) } end |
#rest_node ⇒ Vnode?
10 11 12 |
# File 'lib/yoda/ast/multiple_left_hand_side_node.rb', line 10 def rest_node @rest_node ||= node.children.find { |arg_node| arg_node.type == :restarg } end |