Class: Jekyll::LanguagePlugin::Loaders::BaseLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/language-plugin/loaders/base_loader.rb

Direct Known Subclasses

BuiltinDataLoader, JekyllDataLoader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ BaseLoader

Returns a new instance of BaseLoader.



7
8
9
10
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 7

def initialize(site)
  @site = site
  @is_loaded = false
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



5
6
7
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 5

def site
  @site
end

Instance Method Details

#get(key, language) ⇒ Object



20
21
22
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 20

def get(key, language)
  nil
end

#get_with_placeholders(key, tokens, language) ⇒ Object



24
25
26
27
28
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 24

def get_with_placeholders(key, tokens, language)
  res = get(key, language)
  return nil if res.nil?
  res.gsub(/%%/).with_index { |m, i| tokens[i] || m }
end

#load(language) ⇒ Object



16
17
18
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 16

def load(language)
  true
end

#loaded?(language) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 12

def loaded?(language)
  true
end

#resolve_dot_notation(keys) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 39

def resolve_dot_notation(keys)
  return keys.split('.') if keys.is_a?(String)
  return [] if !keys.is_a?(Enumerable)

  keys.flat_map do |key|
    resolve_dot_notation(key)
  end
end

#traverse_hash(hash, keys) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 30

def traverse_hash(hash, keys)
  for key in keys
    return hash unless hash.is_a?(Hash)
    return nil unless hash.key?(key)
    hash = hash[key]
  end
  hash
end