module Stamp
Constants
- VERSION
Public Instance Methods
stamp(example)
click to toggle source
Formats a date/time using a human-friendly example as a template.
@param [String] example a human-friendly date/time example @param [Hash] options @option options [Boolean] :memoize (true)
@return [String] the formatted date or time
@example
Date.new(2012, 12, 21).stamp("Jan 1, 1999") #=> "Dec 21, 2012"
# File lib/stamp.rb, line 28 def stamp(example) memoize_stamp_emitters(example).format(self) end
Also aliased as: stamp_like, format_like
Private Instance Methods
memoize_stamp_emitters(example)
click to toggle source
Memoizes the set of emitter objects for the given example
in
order to improve performance.
# File lib/stamp.rb, line 38 def memoize_stamp_emitters(example) @@memoized_stamp_emitters ||= {} @@memoized_stamp_emitters[example] ||= stamp_emitters(example) end
stamp_emitters(example)
click to toggle source
# File lib/stamp.rb, line 43 def stamp_emitters(example) emitters = Translator.new.translate(example) Disambiguator.new(emitters).disambiguate! end