Class: Chronic::Dictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/chronic/dictionary.rb

Overview

A collection of definitions

Direct Known Subclasses

SpanDictionary

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Dictionary

Returns a new instance of Dictionary.



8
9
10
11
# File 'lib/chronic/dictionary.rb', line 8

def initialize(options = {})
  @options = options
  @defined_items = []
end

Instance Attribute Details

#defined_itemsObject (readonly)

Returns the value of attribute defined_items.



6
7
8
# File 'lib/chronic/dictionary.rb', line 6

def defined_items
  @defined_items
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/chronic/dictionary.rb', line 6

def options
  @options
end

Instance Method Details

#definitionsObject

returns a hash of each word’s Definitions



14
15
16
17
18
19
# File 'lib/chronic/dictionary.rb', line 14

def definitions
  defined_items.each_with_object({}) do |word, defs|
    word_type = "#{word.capitalize.to_s + 'Definitions'}"
    defs[word] = Chronic.const_get(word_type).new(options).definitions
  end
end