Class: ThatLanguage::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/that_language/store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Store

Returns a new instance of Store.



7
8
9
# File 'lib/that_language/store.rb', line 7

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/that_language/store.rb', line 5

def path
  @path
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/that_language/store.rb', line 23

def exists?
  File.exists?(path)
end

#to_hObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/that_language/store.rb', line 11

def to_h
  Hash.new.tap do |hash|
    within_pstore do
      # FIXME: Change `pstore[:locales]` to pstore[:language_codes]
      hash[:language_codes] = pstore[:locales]
      hash[:language_codes].each do |language_code|
        hash[language_code] = pstore[language_code]
      end
    end
  end
end