Class: IntervalNotation::BasicIntervals::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/interval_notation/basic_intervals.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Point

Returns a new instance of Point.

Raises:



180
181
182
183
# File 'lib/interval_notation/basic_intervals.rb', line 180

def initialize(value)
  raise Error, "Point can't represent an infinity"  unless value.to_f.finite?
  @value = value
end

Instance Method Details

#==(other) ⇒ Object



209
# File 'lib/interval_notation/basic_intervals.rb', line 209

def ==(other); other.is_a?(Point) && value == other.value; end

#closureObject



203
# File 'lib/interval_notation/basic_intervals.rb', line 203

def closure; self; end

#deep_include_position?(pos) ⇒ Boolean

include position and its vicinity (point can’t include vicinity of a position)

Returns:

  • (Boolean)


216
217
218
# File 'lib/interval_notation/basic_intervals.rb', line 216

def deep_include_position?(pos)
  false
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


208
# File 'lib/interval_notation/basic_intervals.rb', line 208

def eql?(other); other.class.equal?(self.class) && value == other.value; end

#finite?Boolean

Returns:

  • (Boolean)


191
# File 'lib/interval_notation/basic_intervals.rb', line 191

def finite?; true; end

#fromObject



184
# File 'lib/interval_notation/basic_intervals.rb', line 184

def from; value; end

#from_finite?Boolean

Returns:

  • (Boolean)


189
# File 'lib/interval_notation/basic_intervals.rb', line 189

def from_finite?; true; end

#from_infinite?Boolean

Returns:

  • (Boolean)


192
# File 'lib/interval_notation/basic_intervals.rb', line 192

def from_infinite?; false; end

#hashObject



207
# File 'lib/interval_notation/basic_intervals.rb', line 207

def hash; @value.hash; end

#include_from?Boolean

Returns:

  • (Boolean)


200
# File 'lib/interval_notation/basic_intervals.rb', line 200

def include_from?; true; end

#include_position?(val) ⇒ Boolean

Returns:

  • (Boolean)


206
# File 'lib/interval_notation/basic_intervals.rb', line 206

def include_position?(val); value == val; end

#include_to?Boolean

Returns:

  • (Boolean)


201
# File 'lib/interval_notation/basic_intervals.rb', line 201

def include_to?; true; end

#infinite?Boolean

Returns:

  • (Boolean)


194
# File 'lib/interval_notation/basic_intervals.rb', line 194

def infinite?; false; end

#inspectObject



198
# File 'lib/interval_notation/basic_intervals.rb', line 198

def inspect; to_s; end

#integer_pointsObject



213
# File 'lib/interval_notation/basic_intervals.rb', line 213

def integer_points; value..value; end

#interval_boundaries(interval_index) ⇒ Object



210
211
212
# File 'lib/interval_notation/basic_intervals.rb', line 210

def interval_boundaries(interval_index)
  BoundaryPoint.new(from, true, nil, interval_index, false)
end

#lengthObject



196
# File 'lib/interval_notation/basic_intervals.rb', line 196

def length; 0; end

#singular_point?Boolean

Returns:

  • (Boolean)


205
# File 'lib/interval_notation/basic_intervals.rb', line 205

def singular_point?; true; end

#toObject



185
# File 'lib/interval_notation/basic_intervals.rb', line 185

def to; value; end

#to_finite?Boolean

Returns:

  • (Boolean)


190
# File 'lib/interval_notation/basic_intervals.rb', line 190

def to_finite?; true; end

#to_infinite?Boolean

Returns:

  • (Boolean)


193
# File 'lib/interval_notation/basic_intervals.rb', line 193

def to_infinite?; false; end

#to_interval_setObject



187
# File 'lib/interval_notation/basic_intervals.rb', line 187

def to_interval_set; IntervalSet.new([self]); end

#to_sObject



197
# File 'lib/interval_notation/basic_intervals.rb', line 197

def to_s; "{#{@value}}"; end