Base class for TExpr classes that can be composed of other TExpr objects imlpemented using the Composite(GoF) pattern.
# File lib/runt/temporalexpression.rb, line 94 def ==(other) if other.is_a?(Collection) o_exprs = other.expressions.dup expressions.each do |e| return false unless i = o_exprs.index(e) o_exprs.delete_at(i) end o_exprs.each {|e| return false unless i == expressions.index(e)} return true else super(other) end end
# File lib/runt/temporalexpression.rb, line 108 def add(anExpression) @expressions.push anExpression self end
# File lib/runt/temporalexpression.rb, line 139 def display puts "I am a #{self.class} containing:" @expressions.each do |ex| pp "#{ex.class}" end end
Will return true if the supplied object overlaps with the range used to create this instance
# File lib/runt/temporalexpression.rb, line 115 def overlap?(date_expr) @expressions.each do | interval | return true if date_expr.overlap?(interval) end false end
# File lib/runt/temporalexpression.rb, line 122 def to_s if !@expressions.empty? && block_given? first_expr, next_exprs = yield result = '' @expressions.map do |expr| if @expressions.first===expr result = first_expr + expr.to_s else result = result + next_exprs + expr.to_s end end result else 'empty' end end
Generated with the Darkfish Rdoc Generator 2.