Class: Zena::Parser::DummyHelper
- Inherits:
-
Object
- Object
- Zena::Parser::DummyHelper
show all
- Defined in:
- lib/zena/parser.rb
Instance Method Summary
collapse
Constructor Details
#initialize(strings = {}) ⇒ DummyHelper
Returns a new instance of DummyHelper.
13
14
15
|
# File 'lib/zena/parser.rb', line 13
def initialize(strings = {})
@strings = strings
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/zena/parser.rb', line 32
def method_missing(sym, *args)
arguments = args.map do |arg|
if arg.kind_of?(Hash)
res = []
arg.each do |k,v|
unless v.nil?
res << "#{k}:#{v.inspect.gsub(/'|"/, "|")}"
end
end
res.sort.join(' ')
else
arg.inspect.gsub(/'|"/, "|")
end
end
res = "[#{sym} #{arguments.join(' ')}]"
end
|
Instance Method Details
#get_template_text(src, base_path) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/zena/parser.rb', line 17
def get_template_text(src, base_path)
base_path = (base_path && base_path != '') ? base_path[1..-1].split('/') : []
src = src[1..-1] if src[0..0] == '/' url = (base_path + src.split('/')).join('_')
if test = @strings[url]
return [test['src'], url.split('_').join('/')]
else
nil
end
end
|
#template_url_for_asset(opts) ⇒ Object
28
29
30
|
# File 'lib/zena/parser.rb', line 28
def template_url_for_asset(opts)
"/test_#{opts[:type]}/#{opts[:src]}"
end
|