Module: Temporal::InstanceMethods

Included in:
Temporal
Defined in:
lib/acts_as_flux_capacitor/temporal.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



82
83
84
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 82

def self.included(base) # :nodoc:
  base.extend ClassMethods
end

Instance Method Details

#after?(obj) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 94

def after?(obj)
  extract_time(self,:begins_at) > extract_time(obj,:ends_at)
end

#after_or_at?(obj) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 98

def after_or_at? obj
  extract_time(self,:ends_at) <= extract_time(obj,:begins_at)
end

#before?(obj) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 86

def before?(obj)
  extract_time(self,:ends_at) < extract_time(obj,:begins_at)
end

#before_or_at?(obj) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 90

def before_or_at? obj
  extract_time(self,:ends_at) <= extract_time(obj,:begins_at)
end

#between?(obj, another_obj) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
105
106
107
108
109
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 102

def between? obj,another_obj
  first_obj,second_obj = ordered_tuple(obj,another_obj)
  beginning_between = extract_time(first_obj,:ends_at)
  ending_between    = extract_time(second_obj,:begins_at)
  
  self.start_time.after_or_at?(beginning_between) && 
  self.end_time.before_or_at?(ending_between)
end

#in_the_future?(time = Time.now) ⇒ Boolean Also known as: future?

Returns:

  • (Boolean)


111
112
113
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 111

def in_the_future?(time = Time.now)
  extract_time(self,:begins_at).after?(time)
end

#in_the_past?(time = Time.now) ⇒ Boolean Also known as: past?

Returns:

  • (Boolean)


116
117
118
# File 'lib/acts_as_flux_capacitor/temporal.rb', line 116

def in_the_past?(time=Time.now)
  extract_time(self,:ends_at).before?(time)
end