Class: CoolHash
- Inherits:
-
Object
- Object
- CoolHash
- Defined in:
- lib/dodiez.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(hash) ⇒ CoolHash
constructor
A new instance of CoolHash.
Constructor Details
#initialize(hash) ⇒ CoolHash
Returns a new instance of CoolHash.
4 5 6 |
# File 'lib/dodiez.rb', line 4 def initialize(hash) @hash = hash end |
Instance Method Details
#[](key) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/dodiez.rb', line 8 def [](key) if needed_type?(key) @hash[key] ? @hash[key] : @hash[key.to_sym] || @hash[key.to_s] else @hash[key] end end |