Class: Rumx::ListBean
Instance Method Summary collapse
- #bean_each_embedded_child(&block) ⇒ Object
-
#bean_find(name_array, index = 0) ⇒ Object
Find the bean.
-
#initialize(list) ⇒ ListBean
constructor
A new instance of ListBean.
Methods included from Bean
add_root, #bean_add_child, #bean_children, #bean_each, #bean_each_child, #bean_each_child_recursive, #bean_each_operation, #bean_each_operation_recursive, #bean_embedded, #bean_get_and_set_attributes, #bean_get_attributes, #bean_has_attributes?, #bean_has_operations?, #bean_monitor, #bean_remove_child, #bean_set_and_get_attributes, #bean_set_attributes, #bean_synchronize, find, find_operation, included, remove_root, root
Constructor Details
#initialize(list) ⇒ ListBean
Returns a new instance of ListBean.
5 6 7 |
# File 'lib/rumx/list_bean.rb', line 5 def initialize(list) @list = list end |
Instance Method Details
#bean_each_embedded_child(&block) ⇒ Object
19 20 21 22 23 |
# File 'lib/rumx/list_bean.rb', line 19 def (&block) @list.each_with_index do |child, i| yield i, child end end |
#bean_find(name_array, index = 0) ⇒ Object
Find the bean
10 11 12 13 14 15 16 17 |
# File 'lib/rumx/list_bean.rb', line 10 def bean_find(name_array, index = 0) return self if index == name_array.size name = name_array[index] return nil unless name.match(/^\d+$/) child = @list[name.to_i] return nil unless child return child.bean_find(name_array, index+1) end |