Class: PhotoUtils::Value

Inherits:
Float
  • Object
show all
Defined in:
lib/photo_utils/value.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Float

#format, #prec

Constructor Details

#initialize(n) ⇒ Value

Returns a new instance of Value.



11
12
13
# File 'lib/photo_utils/value.rb', line 11

def initialize(n)
  super(n.to_f)
end

Class Method Details

.new_from_v(v) ⇒ Object

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/photo_utils/value.rb', line 7

def self.new_from_v(v)
  raise NotImplementedError, "Subclass has not implemented \#new_from_v"
end

Instance Method Details

#<=>(other) ⇒ Object



31
32
33
# File 'lib/photo_utils/value.rb', line 31

def <=>(other)
  self.to_v <=> self.class.new(other).to_v
end

#==(other) ⇒ Object



27
28
29
# File 'lib/photo_utils/value.rb', line 27

def ==(other)
  self.to_v == self.class.new(other).to_v
end

#decrObject



23
24
25
# File 'lib/photo_utils/value.rb', line 23

def decr
  self.class.new_from_v(self.to_v - 1)
end

#incrObject



19
20
21
# File 'lib/photo_utils/value.rb', line 19

def incr
  self.class.new_from_v(self.to_v + 1)
end

#to_vObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/photo_utils/value.rb', line 15

def to_v
  raise NotImplementedError, "Subclass has not implemented \#to_v"
end