Method: Struct#select
- Defined in:
- ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb
#select(&block) ⇒ Object
Calls the given block for each element of self
and returns an array with all elements of which block is not false.
ISO 15.2.18.4.7
40 41 42 43 44 45 46 47 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb', line 40 def select(&block) ary = [] self.class.members.each{|field| val = self[field] ary.push(val) if block.call(val) } ary end |