Class: Temporal::Union
- Inherits:
-
Set
show all
- Defined in:
- lib/temporals/types.rb
Instance Method Summary
collapse
Methods inherited from Set
#[], #set
Constructor Details
#initialize(*args) ⇒ Union
Returns a new instance of Union.
100
101
102
103
|
# File 'lib/temporals/types.rb', line 100
def initialize(*args)
@type = 'UNION'
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Sends all other methods to the set array.
132
133
134
135
136
137
138
139
|
# File 'lib/temporals/types.rb', line 132
def method_missing(name, *args, &block)
if set.respond_to?(name)
args << block if block_given?
set.send(name, *args)
else
super
end
end
|
Instance Method Details
#eql?(other) ⇒ Boolean
117
118
119
120
121
122
123
124
|
# File 'lib/temporals/types.rb', line 117
def eql?(other)
if other.is_a?(Temporal::Union)
set.length == other.length && set.length.times { |i| return false unless set[i].eql? other[i] }
else
raise "Comparison of Temporal::Union with something different (#{other.class.name})."
end
end
|
#include?(other) ⇒ Boolean
105
106
107
|
# File 'lib/temporals/types.rb', line 105
def include?(other)
set.any? {|tp| tp.include?(other)}
end
|
#occurrances_on_day(other) ⇒ Object
113
114
115
|
# File 'lib/temporals/types.rb', line 113
def occurrances_on_day(other)
set.inject([]) {|a,tp| a.concat(tp.occurrances_on_day(other)); a}
end
|
#occurs_on_day?(other) ⇒ Boolean
109
110
111
|
# File 'lib/temporals/types.rb', line 109
def occurs_on_day?(other)
set.any? {|tp| tp.occurs_on_day?(other)}
end
|
#to_natural ⇒ Object
126
127
128
|
# File 'lib/temporals/types.rb', line 126
def to_natural
set.inject([]) {|a,tp| a << tp.to_natural}.join(' and ')
end
|