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:



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

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

Instance Method Details

#==(other) ⇒ Object



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

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

#closureObject



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

def closure; self; end

#deep_include_position?(pos) ⇒ Boolean

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

Returns:

  • (Boolean)


219
220
221
# File 'lib/interval_notation/basic_intervals.rb', line 219

def deep_include_position?(pos)
  false
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#finite?Boolean

Returns:

  • (Boolean)


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

def finite?; true; end

#fromObject



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

def from; value; end

#from_finite?Boolean

Returns:

  • (Boolean)


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

def from_finite?; true; end

#from_infinite?Boolean

Returns:

  • (Boolean)


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

def from_infinite?; false; end

#hashObject



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

def hash; @value.hash; end

#include_from?Boolean

Returns:

  • (Boolean)


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

def include_from?; true; end

#include_position?(val) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#include_to?Boolean

Returns:

  • (Boolean)


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

def include_to?; true; end

#infinite?Boolean

Returns:

  • (Boolean)


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

def infinite?; false; end

#inspectObject



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

def inspect; to_s; end

#integer_pointsObject



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

def integer_points; value..value; end

#interval_boundaries(interval_index) ⇒ Object



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

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

#lengthObject



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

def length; 0; end

#singular_point?Boolean

Returns:

  • (Boolean)


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

def singular_point?; true; end

#toObject



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

def to; value; end

#to_finite?Boolean

Returns:

  • (Boolean)


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

def to_finite?; true; end

#to_infinite?Boolean

Returns:

  • (Boolean)


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

def to_infinite?; false; end

#to_interval_setObject



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

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

#to_sObject



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

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