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.



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

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

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



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

def site
  @site
end

Instance Method Details

#get(key, language) ⇒ Object



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

def get(key, language)
  nil
end

#get_with_placeholders(key, tokens, language) ⇒ Object



27
28
29
30
31
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 27

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



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

def load(language)
  true
end

#loaded?(language) ⇒ Boolean

Returns:

  • (Boolean)


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

def loaded?(language)
  true
end

#resolve_dot_notation(keys) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 42

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



33
34
35
36
37
38
39
40
# File 'lib/jekyll/language-plugin/loaders/base_loader.rb', line 33

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