Class: Hb::Base::KeyFormatter
- Inherits:
-
Object
- Object
- Hb::Base::KeyFormatter
- Defined in:
- lib/hb/key_formatter.rb
Instance Method Summary collapse
- #format(key) ⇒ Object
-
#initialize(*args) ⇒ KeyFormatter
constructor
A new instance of KeyFormatter.
Constructor Details
#initialize(*args) ⇒ KeyFormatter
Returns a new instance of KeyFormatter.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/hb/key_formatter.rb', line 4 def initialize(*args) @format = {} = args. args.each do |name| @format[name] = [] end .each do |name, parameters| @format[name] = parameters end end |
Instance Method Details
#format(key) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hb/key_formatter.rb', line 16 def format(key) @format.reduce(key.to_s) do |result, args| func, args = args if ::Proc === func func.call result, *args else result.send func, *args end end end |