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.
84
85
86
87
88
89
|
# File 'lib/interval_notation/basic_intervals.rb', line 84
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
107
|
# File 'lib/interval_notation/basic_intervals.rb', line 107
def ==(other); other.is_a?(OpenClosedInterval) && from == other.from && to == other.to; end
|
#include_from? ⇒ Boolean
91
|
# File 'lib/interval_notation/basic_intervals.rb', line 91
def include_from?; false; end
|
#include_position?(value) ⇒ Boolean
106
|
# File 'lib/interval_notation/basic_intervals.rb', line 106
def include_position?(value); from < value && value <= to; end
|
#include_to? ⇒ Boolean
92
|
# File 'lib/interval_notation/basic_intervals.rb', line 92
def include_to?; true; end
|
#integer_points ⇒ Object
112
|
# File 'lib/interval_notation/basic_intervals.rb', line 112
def integer_points; (from + 1).floor .. to.floor; end
|
#interval_boundaries(interval_index) ⇒ Object
108
109
110
111
|
# File 'lib/interval_notation/basic_intervals.rb', line 108
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
94
|
# File 'lib/interval_notation/basic_intervals.rb', line 94
def to_finite?; true; end
|
#to_infinite? ⇒ Boolean
95
|
# File 'lib/interval_notation/basic_intervals.rb', line 95
def to_infinite?; false; end
|
#to_s ⇒ Object
90
|
# File 'lib/interval_notation/basic_intervals.rb', line 90
def to_s; "(#{from_to_s};#{to_to_s}]"; end
|
#to_to_s ⇒ Object
96
|
# File 'lib/interval_notation/basic_intervals.rb', line 96
def to_to_s; to; end
|