class LtdTemplate::Proxy::Boolean
Public Instance Methods
do_and(opts)
click to toggle source
Implement */& (and): bool&(bool1, …, boolN) True if ALL booleans are true. Evaluates {} blocks until false.
# File lib/ltdtemplate/proxy/boolean.rb, line 49 def do_and (opts) if @original && (params = opts[:parameters]) params.each(:seq) do |idx, expr| return false unless rubyversed(expr). evaluate(:method => 'call').in_rubyverse(@template). tpl_boolean end end @original end
do_not(opts)
click to toggle source
Implement ! (not): bool!(bool1, …, boolN) True if ALL booleans are false. Evaluates {} blocks until true.
# File lib/ltdtemplate/proxy/boolean.rb, line 63 def do_not (opts) if !@original && (params = opts[:parameters]) params.each(:seq) do |idx, expr| return false if rubyversed(expr). evaluate(:method => 'call').in_rubyverse(@template). to_boolean end end !@original end
do_or(opts)
click to toggle source
Implement +/| (or): bool|(bool1, …, boolN) True if ANY boolean is true. Evaluates {} blocks until true.
# File lib/ltdtemplate/proxy/boolean.rb, line 36 def do_or (opts) if !@original && (params = opts[:parameters]) params.each(:seq) do |idx, expr| return true if rubyversed(expr).evaluate(:method => 'call'). in_rubyverse(@template).tpl_boolean end end @original end
evaluate(opts = {})
click to toggle source
Evaluate supported methods on boolean objects.
Calls superclass method
LtdTemplate::Value#evaluate
# File lib/ltdtemplate/proxy/boolean.rb, line 12 def evaluate (opts = {}) case opts[:method] when nil, 'call' then @original when 'class' then 'Boolean' when 'str', 'string' then @original ? 'true' : 'false' when 'type' then 'boolean' when '+', '|', 'or' then do_or opts when '*', '&', 'and' then do_and opts when '!', 'not' then do_not opts else super opts end end
tpl_boolean()
click to toggle source
The template boolean value is the same as the original boolean value.
# File lib/ltdtemplate/proxy/boolean.rb, line 26 def tpl_boolean; @original; end
tpl_text()
click to toggle source
Booleans have no textual value in templates.
# File lib/ltdtemplate/proxy/boolean.rb, line 29 def tpl_text; ''; end