Class: Translator::LanguageBundle
- Inherits:
-
Object
- Object
- Translator::LanguageBundle
- Defined in:
- lib/natural-date/language_bundle.rb
Instance Attribute Summary collapse
-
#months ⇒ Object
readonly
Returns the value of attribute months.
-
#separator_regexp ⇒ Object
readonly
Returns the value of attribute separator_regexp.
-
#types_map ⇒ Object
readonly
Returns the value of attribute types_map.
-
#types_range ⇒ Object
readonly
Returns the value of attribute types_range.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#values_map ⇒ Object
readonly
Returns the value of attribute values_map.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lang) ⇒ LanguageBundle
constructor
A new instance of LanguageBundle.
Constructor Details
#initialize(lang) ⇒ LanguageBundle
Returns a new instance of LanguageBundle.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/natural-date/language_bundle.rb', line 7 def initialize lang @lang = lang.freeze @types_range = { week_day: 0..6, month: 1..12 }.freeze @types_map = load_types_map.freeze @values = load_values.freeze @months = load_months.freeze @values_map = @values.map { |key, value| value.split(' ').map { |v| { v => key } } }.flatten.reduce({}) { |e, map| map.merge(e) }.freeze @separator_regexp = Regexp.new(@types_map.select { |_k, v| v == :separator }.keys.map { |k| " #{k} " }.join '|').freeze end |
Instance Attribute Details
#months ⇒ Object (readonly)
Returns the value of attribute months.
5 6 7 |
# File 'lib/natural-date/language_bundle.rb', line 5 def months @months end |
#separator_regexp ⇒ Object (readonly)
Returns the value of attribute separator_regexp.
5 6 7 |
# File 'lib/natural-date/language_bundle.rb', line 5 def separator_regexp @separator_regexp end |
#types_map ⇒ Object (readonly)
Returns the value of attribute types_map.
5 6 7 |
# File 'lib/natural-date/language_bundle.rb', line 5 def types_map @types_map end |
#types_range ⇒ Object (readonly)
Returns the value of attribute types_range.
5 6 7 |
# File 'lib/natural-date/language_bundle.rb', line 5 def types_range @types_range end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
5 6 7 |
# File 'lib/natural-date/language_bundle.rb', line 5 def values @values end |
#values_map ⇒ Object (readonly)
Returns the value of attribute values_map.
5 6 7 |
# File 'lib/natural-date/language_bundle.rb', line 5 def values_map @values_map end |
Class Method Details
.fetch(lang) ⇒ Object
18 19 20 |
# File 'lib/natural-date/language_bundle.rb', line 18 def self.fetch lang BUNDLES[lang] ||= LanguageBundle.new(lang) end |