Class: Microformats::MethodHash
- Inherits:
-
Object
- Object
- Microformats::MethodHash
show all
- Defined in:
- lib/uformats.rb
Overview
Provides method access to an internal Hash
Instance Method Summary
collapse
Constructor Details
#initialize(hash = {}) ⇒ MethodHash
Returns a new instance of MethodHash.
14
15
16
|
# File 'lib/uformats.rb', line 14
def initialize(hash={})
@hash = hash.dup
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
26
27
28
|
# File 'lib/uformats.rb', line 26
def method_missing(sym, *args)
return Pluralizer.singularized_lookup(self, sym)
end
|
Instance Method Details
#[](k) ⇒ Object
22
23
24
|
# File 'lib/uformats.rb', line 22
def [](k)
return @hash[k]
end
|
#[]=(k, v) ⇒ Object
18
19
20
|
# File 'lib/uformats.rb', line 18
def []=(k,v)
@hash[k] = v
end
|
#each(&blk) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/uformats.rb', line 30
def each(&blk)
case blk.arity
when 1
@hash.each do |k,v|
yield [k, v]
end
when 2
@hash.each do |k,v|
yield k, v
end
end
end
|