Class: Stamp::Emitters::Delegate

Inherits:
Object
  • Object
show all
Defined in:
lib/stamp/emitters/delegate.rb

Constant Summary collapse

ZONE =
new(:zone,  "%Z")
YEAR =
new(:year,  "%Y")
MONTH =
new(:month, "%-m")
DAY =
new(:day,   "%-d")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, strftime_directive) ⇒ Delegate

Returns a new instance of Delegate.

Parameters:

  • field (Symbol|String)

    the field to be formatted (e.g. :month, :year)



7
8
9
10
# File 'lib/stamp/emitters/delegate.rb', line 7

def initialize(field, strftime_directive)
  @field = field
  @strftime_directive = strftime_directive
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



4
5
6
# File 'lib/stamp/emitters/delegate.rb', line 4

def field
  @field
end

#strftime_directiveObject (readonly)

Returns the value of attribute strftime_directive.



4
5
6
# File 'lib/stamp/emitters/delegate.rb', line 4

def strftime_directive
  @strftime_directive
end

Instance Method Details

#format(target) ⇒ Object

Parameters:

  • target (Date|Time|DateTime)

    the date to be formatted



13
14
15
# File 'lib/stamp/emitters/delegate.rb', line 13

def format(target)
  target.send(field)
end