Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/asciitracker/hash_ext.rb,
lib/asciitracker/hash_ext.rb
Instance Method Summary collapse
- #/(key) ⇒ Object
-
#method_missing(m, *a) ⇒ Object
_why’s hash implant with a twist: the difference is to throw a NoMethodError instead returning nil when asking for a non-existing value.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a) ⇒ Object
_why’s hash implant with a twist: the difference is to throw a NoMethodError instead returning nil when asking for a non-existing value
6 7 8 9 10 11 12 13 14 |
# File 'lib/asciitracker/hash_ext.rb', line 6 def method_missing(m,*a) if m.to_s =~ /=$/ self[$`.to_sym] = a[0] elsif a.empty? self[m] else raise NoMethodError, "#{m}" end end |
Instance Method Details
#/(key) ⇒ Object
1 |
# File 'lib/asciitracker/hash_ext.rb', line 1 def /(key);self[key];end |