Class: Temporal::Classification
Class Attribute Summary collapse
-
.order ⇒ Object
readonly
Returns the value of attribute order.
-
.translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
-
#ord ⇒ Object
readonly
Returns the value of attribute ord.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(word) ⇒ Classification
constructor
A new instance of Classification.
Constructor Details
#initialize(word) ⇒ Classification
Returns a new instance of Classification.
31 32 33 34 |
# File 'lib/temporals/types.rb', line 31 def initialize(word) @name = word.is_a?(String) ? self.class.normalize(word) : self.class.order[word] @ord = self.class.order.index(@name) end |
Class Attribute Details
.order ⇒ Object (readonly)
Returns the value of attribute order.
12 13 14 |
# File 'lib/temporals/types.rb', line 12 def order @order end |
.translations ⇒ Object (readonly)
Returns the value of attribute translations.
12 13 14 |
# File 'lib/temporals/types.rb', line 12 def translations @translations end |
Instance Attribute Details
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
27 28 29 |
# File 'lib/temporals/types.rb', line 27 def name @name end |
#ord ⇒ Object (readonly)
Returns the value of attribute ord.
27 28 29 |
# File 'lib/temporals/types.rb', line 27 def ord @ord end |
Class Method Details
.abbreviations ⇒ Object
14 15 16 17 18 19 |
# File 'lib/temporals/types.rb', line 14 def abbreviations @abbreviations ||= translations.inject({}) do |h,(k,v)| h[v] = k unless h.has_key?(v) && h[v].length < k.length h end end |
.normalize(word) ⇒ Object
21 22 23 24 |
# File 'lib/temporals/types.rb', line 21 def normalize(word) word = word.capitalize order.include?(word) ? word : (translations.has_key?(word) ? translations[word] : nil) end |