Sha256: 5b5cb37bafed1c013250256a94658077d5762c17fa771fea8a467de6f01ade96
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'chronic/definition' module Chronic # A collection of definitions class Dictionary attr_reader :defined_items, :options def initialize(options = {}) @options = options @defined_items = [] end # returns a hash of each word's Definitions def definitions defined_items.each_with_object({}) do |word, defs| word_type = "#{word.to_s.split('_').map(&:capitalize).join + 'Definitions'}" defs[word] = Chronic.const_get(word_type).new(options).definitions end end end class SpanDictionary < Dictionary # Collection of SpanDefinitions def initialize(options = {}) super @defined_items = [:time, :date, :short_date, :timezone, :date_time, :anchor, :arrow, :narrow, :endian] end # returns the definitions of a specific subclass of SpanDefinitions # SpanDefinition#definitions returns an Hash of Handler instances # arguments should come in as symbols def [](handler_type=:symbol) definitions[handler_type] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chronic-davispuh-0.10.2.v0.1da32066b3f46f2506b3471e39557497e34afa27 | lib/chronic/dictionary.rb |