class Applyrics::LanguageFile
Public Class Methods
new(path, data=nil)
click to toggle source
# File lib/applyrics/languagefile.rb, line 7 def initialize(path, data=nil) @path = path @hash = data if data.nil? read end end
Public Instance Methods
[](key)
click to toggle source
# File lib/applyrics/languagefile.rb, line 15 def [](key) @hash[key] end
[]=(key, value)
click to toggle source
# File lib/applyrics/languagefile.rb, line 19 def []=(key, value) @hash[key] = value end
language?(key)
click to toggle source
# File lib/applyrics/languagefile.rb, line 23 def language?(key) @hash.key?(key) end
languages()
click to toggle source
# File lib/applyrics/languagefile.rb, line 27 def languages @hash.keys end
read()
click to toggle source
# File lib/applyrics/languagefile.rb, line 31 def read @hash = {} data = File.read(@path) @hash = MultiJson.load(data) end
to_hash()
click to toggle source
# File lib/applyrics/languagefile.rb, line 37 def to_hash @hash end
write()
click to toggle source
# File lib/applyrics/languagefile.rb, line 41 def write() File.open(@path, 'w') { |file| file.write(MultiJson.dump(@hash, :pretty => true)) } end