Class: DeepStruct::Array
- Inherits:
-
Array
- Object
- Array
- DeepStruct::Array
- Defined in:
- lib/deep_struct/array.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
-
#first ⇒ Object
The annoyance of subclassing Array is that ruby implements many array methods directly in C, bypassing my pretty little [] method above.
- #sample(*args) ⇒ Object
Instance Method Details
#[](index) ⇒ Object
2 3 4 |
# File 'lib/deep_struct/array.rb', line 2 def [](index) DeepStruct.convert_element_if_possible(super) end |
#each(&block) ⇒ Object
14 15 16 17 18 |
# File 'lib/deep_struct/array.rb', line 14 def each(&block) super do |e| block.call(DeepStruct.convert_element_if_possible(e)) end end |
#first ⇒ Object
The annoyance of subclassing Array is that ruby implements many array methods directly in C, bypassing my pretty little [] method above. I expect to implement many methods like #first in the future
10 11 12 |
# File 'lib/deep_struct/array.rb', line 10 def first self[0] end |
#sample(*args) ⇒ Object
20 21 22 |
# File 'lib/deep_struct/array.rb', line 20 def sample(*args) DeepStruct.convert_element_if_possible(super) end |