class Ddate::Formatter

Constants

DEFAULT_FORMAT
SPLIT_STOP
STTIBS_RE

Attributes

standard[R]
sttibs[R]

Public Class Methods

new(format = nil) click to toggle source
# File lib/ddate/formatter.rb, line 12
def initialize(format = nil)
  format = DEFAULT_FORMAT if format.to_s.empty?
  @standard = create_format_string_from(format.gsub(STTIBS_RE){$1})
  @sttibs = create_format_string_from(format.gsub(STTIBS_RE, '%{st_tibs_day}'))
end

Public Instance Methods

create_format_string_from(format_string) click to toggle source
# File lib/ddate/formatter.rb, line 18
def create_format_string_from(format_string)
  format_string.gsub(/%[AaBbdeHNntY.X]/, {
      '%A' => '%{dayname}', '%a' => '%{dayname_short}',
      '%B' => '%{seasonname}', '%b' => '%{seasonname_short}',
      '%d' => '%{day}', '%e' => '%{dayth}',
      '%H' => '%{holiday}', '%N' => SPLIT_STOP,
      '%n' => "\n", '%t' => "\t",
      '%Y' => '%{year}', '%.' => '%{exclaim}',
      '%X' => '%{kill_bob}',
  } )

end
split(key) click to toggle source
# File lib/ddate/formatter.rb, line 31
def split(key)
  send(key).split(SPLIT_STOP, 2)
end