Class: MongoidOccurrences::DailyOccurrence

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, HasScopes
Defined in:
lib/mongoid_occurrences/daily_occurrence.rb,
lib/mongoid_occurrences/daily_occurrence/has_scopes.rb

Defined Under Namespace

Modules: HasScopes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasScopes

included

Instance Attribute Details

#operatorObject

Returns the value of attribute operator.



8
9
10
# File 'lib/mongoid_occurrences/daily_occurrence.rb', line 8

def operator
  @operator
end

Instance Method Details

#<=>(other) ⇒ Object



28
29
30
# File 'lib/mongoid_occurrences/daily_occurrence.rb', line 28

def <=>(other)
  sort_key <=> other.sort_key
end

#all_dayObject Also known as: all_day?



22
23
24
25
# File 'lib/mongoid_occurrences/daily_occurrence.rb', line 22

def all_day
  dtstart.to_i == dtstart.beginning_of_day.to_i &&
    dtend.to_i == dtend.end_of_day.to_i
end

#overlaps?(occurrence) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/mongoid_occurrences/daily_occurrence.rb', line 40

def overlaps?(occurrence)
  to_range.overlaps?(occurrence.to_range)
end

#sort_keyObject



32
33
34
# File 'lib/mongoid_occurrences/daily_occurrence.rb', line 32

def sort_key
  [dtstart, dtend]
end

#to_rangeObject



36
37
38
# File 'lib/mongoid_occurrences/daily_occurrence.rb', line 36

def to_range
  (dtstart..dtend)
end