Class: IntervalNotation::BasicIntervals::ClosedClosedInterval
- Inherits:
-
Object
- Object
- IntervalNotation::BasicIntervals::ClosedClosedInterval
show all
- Includes:
- ActslikeInterval
- Defined in:
- lib/interval_notation/basic_intervals.rb
Instance Method Summary
collapse
#deep_include_position?, #eql?, #hash, included, #inspect, #length, #singular_point?, #to_interval_set
Constructor Details
Returns a new instance of ClosedClosedInterval.
150
151
152
153
154
155
|
# File 'lib/interval_notation/basic_intervals.rb', line 150
def initialize(from, to)
raise Error, "Interval [#{from};#{to}] can't be created" unless from < to
raise Error, "Infinite boundary should be open" unless from.to_f.finite? && to.to_f.finite?
@from = from
@to = to
end
|
Instance Method Details
#==(other) ⇒ Object
172
|
# File 'lib/interval_notation/basic_intervals.rb', line 172
def ==(other); other.is_a?(ClosedClosedInterval) && from == other.from && to == other.to; end
|
#closure ⇒ Object
169
|
# File 'lib/interval_notation/basic_intervals.rb', line 169
def closure; self; end
|
#finite? ⇒ Boolean
162
|
# File 'lib/interval_notation/basic_intervals.rb', line 162
def finite?; true; end
|
#from_finite? ⇒ Boolean
160
|
# File 'lib/interval_notation/basic_intervals.rb', line 160
def from_finite?; true; end
|
#from_infinite? ⇒ Boolean
163
|
# File 'lib/interval_notation/basic_intervals.rb', line 163
def from_infinite?; false; end
|
#from_to_s ⇒ Object
166
|
# File 'lib/interval_notation/basic_intervals.rb', line 166
def from_to_s; from; end
|
#include_from? ⇒ Boolean
157
|
# File 'lib/interval_notation/basic_intervals.rb', line 157
def include_from?; true; end
|
#include_position?(value) ⇒ Boolean
171
|
# File 'lib/interval_notation/basic_intervals.rb', line 171
def include_position?(value); from <= value && value <= to; end
|
#include_to? ⇒ Boolean
158
|
# File 'lib/interval_notation/basic_intervals.rb', line 158
def include_to?; true; end
|
#infinite? ⇒ Boolean
165
|
# File 'lib/interval_notation/basic_intervals.rb', line 165
def infinite?; false; end
|
#integer_points ⇒ Object
177
|
# File 'lib/interval_notation/basic_intervals.rb', line 177
def integer_points; from.ceil .. to.floor; end
|
#interval_boundaries(interval_index) ⇒ Object
173
174
175
176
|
# File 'lib/interval_notation/basic_intervals.rb', line 173
def interval_boundaries(interval_index)
[ BoundaryPoint.new(from, true, true, interval_index, true),
BoundaryPoint.new(to, true, false, interval_index, true) ]
end
|
#to_finite? ⇒ Boolean
161
|
# File 'lib/interval_notation/basic_intervals.rb', line 161
def to_finite?; true; end
|
#to_infinite? ⇒ Boolean
164
|
# File 'lib/interval_notation/basic_intervals.rb', line 164
def to_infinite?; false; end
|
#to_s ⇒ Object
156
|
# File 'lib/interval_notation/basic_intervals.rb', line 156
def to_s; "[#{from_to_s};#{to_to_s}]"; end
|
#to_to_s ⇒ Object
167
|
# File 'lib/interval_notation/basic_intervals.rb', line 167
def to_to_s; to; end
|