Class: IntervalNotation::BasicIntervals::OpenClosedInterval
- Inherits:
-
Object
- Object
- IntervalNotation::BasicIntervals::OpenClosedInterval
show all
- Includes:
- ActslikeInterval
- Defined in:
- lib/interval_notation/basic_intervals.rb
Instance Method Summary
collapse
#deep_include_position?, #eql?, #finite?, #from_finite?, #from_infinite?, #from_to_s, #hash, included, #infinite?, #inspect, #length, #singular_point?, #to_interval_set
Constructor Details
Returns a new instance of OpenClosedInterval.
81
82
83
84
85
86
|
# File 'lib/interval_notation/basic_intervals.rb', line 81
def initialize(from, to)
raise Error, "Interval (#{from};#{to}] can't be created" unless from < to
raise Error, "Infinite boundary should be open" unless to.to_f.finite?
@from = from
@to = to
end
|
Instance Method Details
#==(other) ⇒ Object
104
|
# File 'lib/interval_notation/basic_intervals.rb', line 104
def ==(other); other.is_a?(OpenClosedInterval) && from == other.from && to == other.to; end
|
#closure ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/interval_notation/basic_intervals.rb', line 95
def closure
if from_finite?
ClosedClosedInterval.new(from, to)
else
OpenClosedInterval.new(from, to)
end
end
|
#include_from? ⇒ Boolean
88
|
# File 'lib/interval_notation/basic_intervals.rb', line 88
def include_from?; false; end
|
#include_position?(value) ⇒ Boolean
103
|
# File 'lib/interval_notation/basic_intervals.rb', line 103
def include_position?(value); from < value && value <= to; end
|
#include_to? ⇒ Boolean
89
|
# File 'lib/interval_notation/basic_intervals.rb', line 89
def include_to?; true; end
|
#integer_points ⇒ Object
109
|
# File 'lib/interval_notation/basic_intervals.rb', line 109
def integer_points; (from + 1).floor .. to.floor; end
|
#interval_boundaries(interval_index) ⇒ Object
105
106
107
108
|
# File 'lib/interval_notation/basic_intervals.rb', line 105
def interval_boundaries(interval_index)
[ BoundaryPoint.new(from, false, true, interval_index, true),
BoundaryPoint.new(to, true, false, interval_index, true) ]
end
|
#to_finite? ⇒ Boolean
91
|
# File 'lib/interval_notation/basic_intervals.rb', line 91
def to_finite?; true; end
|
#to_infinite? ⇒ Boolean
92
|
# File 'lib/interval_notation/basic_intervals.rb', line 92
def to_infinite?; false; end
|
#to_s ⇒ Object
87
|
# File 'lib/interval_notation/basic_intervals.rb', line 87
def to_s; "(#{from_to_s};#{to_to_s}]"; end
|
#to_to_s ⇒ Object
93
|
# File 'lib/interval_notation/basic_intervals.rb', line 93
def to_to_s; to; end
|