Module: JSI::PathedArrayNode
Constant Summary
Constants included from Arraylike
Arraylike::DESTRUCTIVE_METHODS, Arraylike::SAFE_INDEX_ELEMENT_METHODS, Arraylike::SAFE_INDEX_ONLY_METHODS, Arraylike::SAFE_METHODS
Instance Method Summary collapse
-
#each {|Object| ... } ⇒ self, Enumerator
yields each array element of this node.
-
#node_content_ary_pubsend(method_name, *a, &b) ⇒ Object
The result of calling method method_name on the node_content or its #to_ary.
-
#to_ary ⇒ Array
An array, the same size as the node_content, in which the element at each index is the result of selfindex.
Methods included from Arraylike
Instance Method Details
#each {|Object| ... } ⇒ self, Enumerator
yields each array element of this node.
each yielded element is the result of self[index] for each index of our array (see #[]).
returns an Enumerator if no block is given.
85 86 87 88 89 |
# File 'lib/jsi/pathed_node.rb', line 85 def each return to_enum(__method__) { node_content_ary_pubsend(:size) } unless block_given? node_content_ary_pubsend(:each_index) { |i| yield(self[i]) } self end |
#node_content_ary_pubsend(method_name, *a, &b) ⇒ Object
Returns the result of calling method method_name on the node_content or its #to_ary.
102 103 104 105 106 107 108 |
# File 'lib/jsi/pathed_node.rb', line 102 def node_content_ary_pubsend(method_name, *a, &b) if node_content.respond_to?(method_name) node_content.public_send(method_name, *a, &b) else node_content.to_ary.public_send(method_name, *a, &b) end end |
#to_ary ⇒ Array
Returns an array, the same size as the node_content, in which the element at each index is the result of selfindex.
93 94 95 |
# File 'lib/jsi/pathed_node.rb', line 93 def to_ary to_a end |