# File lib/ruote/exp/condition.rb, line 33 def self.apply? (sif, sunless) return (true?(sif)) if sif return ( ! true?(sunless)) if sunless true end
TODO : rconditional
is it really necessary ? there is already ${r:xxx}
# File lib/ruote/exp/condition.rb, line 44 def self.true? (conditional) conditional = unescape(conditional) if m = SET_REGEX.match(conditional) eval_is(m) elsif m = COMPARISON_REGEX.match(conditional) compare(m) else to_b(conditional) end end
# File lib/ruote/exp/condition.rb, line 83 def self.compare (m) return (m[1].=~(Regexp.new(m[3])) != nil) if m[2] == '=~' a = narrow_to_f(m[1]) b = narrow_to_f(m[3]) if a.class != b.class a = m[1] b = m[3] end #a.send(m[2], b) # ruby 1.8.x doesn't like that one a = strip(a) b = strip(b) m[2] == '!=' ? ( ! a.send('==', b)) : a.send(m[2], b) end
# File lib/ruote/exp/condition.rb, line 59 def self.eval_is (match) match = match[1..-2].select { |e| e != nil } negative = match.find { |m| m == ' not' } first = match.first.strip is_set = first != '' && first != 'is' negative ? (not is_set) : is_set end
# File lib/ruote/exp/condition.rb, line 104 def self.narrow_to_f (s) Float(s) rescue s end
# File lib/ruote/exp/condition.rb, line 109 def self.strip (s) s.respond_to?(:strip) ? s.strip : s end
Generated with the Darkfish Rdoc Generator 2.