Class: Stamp::Emitters::Lookup
- Inherits:
-
Object
- Object
- Stamp::Emitters::Lookup
- Defined in:
- lib/stamp/emitters/lookup.rb
Constant Summary collapse
- MONTH =
new(:month, Date::MONTHNAMES, "%B")
- ABBR_MONTH =
new(:month, Date::ABBR_MONTHNAMES, "%b")
- DAY =
new(:wday, Date::DAYNAMES, "%A")
- ABBR_DAY =
new(:wday, Date::ABBR_DAYNAMES, "%a")
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#strftime_directive ⇒ Object
readonly
Returns the value of attribute strftime_directive.
Instance Method Summary collapse
- #format(target) ⇒ Object
-
#initialize(field, lookup, strftime_directive) ⇒ Lookup
constructor
A new instance of Lookup.
- #lookup(value) ⇒ Object
Constructor Details
#initialize(field, lookup, strftime_directive) ⇒ Lookup
Returns a new instance of Lookup.
8 9 10 11 12 |
# File 'lib/stamp/emitters/lookup.rb', line 8 def initialize(field, lookup, strftime_directive) @field = field @lookup = lookup @strftime_directive = strftime_directive end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
4 5 6 |
# File 'lib/stamp/emitters/lookup.rb', line 4 def field @field end |
#strftime_directive ⇒ Object (readonly)
Returns the value of attribute strftime_directive.
4 5 6 |
# File 'lib/stamp/emitters/lookup.rb', line 4 def strftime_directive @strftime_directive end |
Instance Method Details
#format(target) ⇒ Object
14 15 16 |
# File 'lib/stamp/emitters/lookup.rb', line 14 def format(target) lookup(target.send(field)) end |
#lookup(value) ⇒ Object
18 19 20 |
# File 'lib/stamp/emitters/lookup.rb', line 18 def lookup(value) @lookup[value] end |