Class: Runt::TemporalRange

Inherits:
TemporalDate show all
Defined in:
lib/runt/temporalexpression.rb

Overview

TExpr that provides a thin wrapper around built-in Ruby Range functionality facilitating inclusion of an arbitrary range in a temporal expression.

See also: Range

Instance Attribute Summary

Attributes inherited from TemporalDate

#date_expr

Instance Method Summary collapse

Methods inherited from TemporalDate

#initialize, #to_s

Methods included from TExpr

#&, #-, #and, #dates, #minus, #or, #to_s, #|

Constructor Details

This class inherits a constructor from Runt::TemporalDate

Instance Method Details

#==(o) ⇒ Object



250
251
252
# File 'lib/runt/temporalexpression.rb', line 250

def ==(o)
  o.is_a?(TemporalRange) ? date_expr == o.date_expr : super(o)
end

#include?(date_expr) ⇒ Boolean

Will return true if the supplied object is included in the range used to create this instance

Returns:

  • (Boolean)


246
247
248
# File 'lib/runt/temporalexpression.rb', line 246

def include?(date_expr)
  return @date_expr.include?(date_expr)
end

#overlap?(date_expr) ⇒ Boolean

Will return true if the supplied object overlaps with the range used to create this instance

Returns:

  • (Boolean)


256
257
258
259
260
261
# File 'lib/runt/temporalexpression.rb', line 256

def overlap?(date_expr)
  @date_expr.each do | interval |
    return true if date_expr.include?(interval)      
  end
  false    
end