Class: Translate::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/translate/storage.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale) ⇒ Storage

Returns a new instance of Storage.



4
5
6
# File 'lib/translate/storage.rb', line 4

def initialize(locale)
  self.locale = locale.to_sym
end

Instance Attribute Details

#localeObject

Returns the value of attribute locale.



2
3
4
# File 'lib/translate/storage.rb', line 2

def locale
  @locale
end

Class Method Details

.file_paths(locale) ⇒ Object



16
17
18
# File 'lib/translate/storage.rb', line 16

def self.file_paths(locale)
  Dir.glob(File.join(root_dir, "config", "locales", "**","#{locale}.yml"))
end

.root_dirObject



20
21
22
# File 'lib/translate/storage.rb', line 20

def self.root_dir
  Rails.root
end

Instance Method Details

#read_from_fileObject



12
13
14
# File 'lib/translate/storage.rb', line 12

def read_from_file
  Translate::File.new(file_path).read_raw()
end

#write_to_fileObject



8
9
10
# File 'lib/translate/storage.rb', line 8

def write_to_file
  Translate::File.new(file_path).write(keys)
end