Class: DeepStruct::Array
- Inherits:
-
Array
- Object
- Array
- DeepStruct::Array
- Defined in:
- lib/deep_struct/array.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#first ⇒ Object
The annoyance of subclassing Array is that ruby implements many array methods directly in C, bypassing my pretty little [] method above.
Instance Method Details
#[](index) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/deep_struct/array.rb', line 2 def [](index) v = super return DeepStruct::Hash.new(v) if v.is_a?(::Hash) return DeepStruct::Array.new(v) if v.is_a?(::Array) return v 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
13 14 15 |
# File 'lib/deep_struct/array.rb', line 13 def first self[0] end |