Parent

Stamp::Emitters::Lookup

Attributes

field[R]

Public Class Methods

new(field, lookup=nil) click to toggle source

@param [field] the field to be formatted (e.g. :month, :year) @param [lookup] an array of the string values to be formatted (e.g. +Date::DAYNAMES+)

or a +call+able that returns the formatted value
# File lib/stamp/emitters/lookup.rb, line 9
def initialize(field, lookup=nil)
  @field = field
  @lookup = lookup
end

Public Instance Methods

format(target) click to toggle source
# File lib/stamp/emitters/lookup.rb, line 14
def format(target)
  lookup(target.send(field))
end
lookup(value) click to toggle source
# File lib/stamp/emitters/lookup.rb, line 18
def lookup(value)
  if @lookup.respond_to?(:call)
    @lookup.call(value)
  else
    @lookup[value]
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.