Class: I18nSpec::LocaleFile
- Inherits:
-
Object
- Object
- I18nSpec::LocaleFile
- Defined in:
- lib/i18n-spec/models/locale_file.rb
Constant Summary collapse
- PLURALIZATION_KEYS =
%w{zero one two few many other}
Instance Method Summary collapse
- #has_valid_pluralization_keys? ⇒ Boolean
-
#initialize(filepath) ⇒ LocaleFile
constructor
A new instance of LocaleFile.
- #is_parseable? ⇒ Boolean
Constructor Details
#initialize(filepath) ⇒ LocaleFile
Returns a new instance of LocaleFile.
5 6 7 |
# File 'lib/i18n-spec/models/locale_file.rb', line 5 def initialize(filepath) @filepath = filepath end |
Instance Method Details
#has_valid_pluralization_keys? ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/i18n-spec/models/locale_file.rb', line 18 def has_valid_pluralization_keys? pluralizations.each do |key, pluralization| return false unless pluralization.keys.all? {|k| PLURALIZATION_KEYS.include?(k)} end true end |
#is_parseable? ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/i18n-spec/models/locale_file.rb', line 9 def is_parseable? begin Psych.load_file(@filepath) true rescue Psych::SyntaxError => e false end end |