Class: Jekyll::LanguagePlugin::Loaders::BuiltinDataLoader
- Inherits:
-
BaseLoader
- Object
- BaseLoader
- Jekyll::LanguagePlugin::Loaders::BuiltinDataLoader
- Defined in:
- lib/jekyll/language-plugin/loaders/builtin_data_loader.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes inherited from BaseLoader
Instance Method Summary collapse
- #get(key, language) ⇒ Object
-
#initialize(site) ⇒ BuiltinDataLoader
constructor
A new instance of BuiltinDataLoader.
- #load(language) ⇒ Object
- #loaded?(language) ⇒ Boolean
Methods inherited from BaseLoader
#get_with_placeholders, #resolve_dot_notation, #traverse_hash
Constructor Details
#initialize(site) ⇒ BuiltinDataLoader
Returns a new instance of BuiltinDataLoader.
13 14 15 16 |
# File 'lib/jekyll/language-plugin/loaders/builtin_data_loader.rb', line 13 def initialize(site) super @data = Hash.new end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/jekyll/language-plugin/loaders/builtin_data_loader.rb', line 11 def data @data end |
Instance Method Details
#get(key, language) ⇒ Object
31 32 33 34 35 |
# File 'lib/jekyll/language-plugin/loaders/builtin_data_loader.rb', line 31 def get(key, language) return nil unless loaded?(language) traverse_hash(@data, resolve_dot_notation([language, key])) end |
#load(language) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/jekyll/language-plugin/loaders/builtin_data_loader.rb', line 22 def load(language) return true if loaded?(language) file = File.(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'data', 'lang', "#{language}.yml")) return false unless File.file?(file) !!@data.merge!(YAML.load_file(file)); end |
#loaded?(language) ⇒ Boolean
18 19 20 |
# File 'lib/jekyll/language-plugin/loaders/builtin_data_loader.rb', line 18 def loaded?(language) @data.has_key?(language) end |