Class: EPUBMaker::Resource

Inherits:
Object show all
Defined in:
lib/epubmaker/resource.rb

Overview

EPUBMaker::Resource contains message translation resources for EPUBMaker.

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Resource

Construct message resource object with using params[“language”] value.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/epubmaker/resource.rb', line 17

def initialize(params)
  @hash = nil
  begin
    @hash = __send__ params["language"]
  rescue
    @hash = __send__ :en
  end
  
  @hash.each_pair do |k, v|
    @hash[k] = params[k] unless params[k].nil?
  end
end

Instance Method Details

#v(key) ⇒ Object

Return message translation for key.



31
32
33
# File 'lib/epubmaker/resource.rb', line 31

def v(key)
  return @hash[key]
end