Class: GenericLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/bigcommerce_tool/generic_lookup.rb

Instance Method Summary collapse

Constructor Details

#initialize(yaml_path) ⇒ GenericLookup

Returns a new instance of GenericLookup.



2
3
4
# File 'lib/bigcommerce_tool/generic_lookup.rb', line 2

def initialize(yaml_path)
  @translations = YAML::load(File.open(File.join(Dir.pwd, yaml_path)))
end

Instance Method Details

#lookup(key) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/bigcommerce_tool/generic_lookup.rb', line 14

def lookup(key)
  if @translations.has_key?(key)
    @translations[key]
  else
    puts render_in_div(key)
    #puts "  --- missing (#{self.class} lookup): #{key}" #unless @translations.has_key?(key)
    #puts "#{code}#{key}: '%%#{code}#{key}%%'"
    "#{self.code}#{key}"
  end
end

#merge_additional_options(hsh) ⇒ Object



6
7
8
# File 'lib/bigcommerce_tool/generic_lookup.rb', line 6

def merge_additional_options(hsh)
  @translations.merge!(hsh)
end

#render_in_div(key) ⇒ Object



10
11
12
# File 'lib/bigcommerce_tool/generic_lookup.rb', line 10

def render_in_div(key)
  "<div style='border:1px solid red'>#{code}#{key}: [-- %%#{code}#{key}%% --]</div>"
end