Class: PhotoUtils::Value
- Inherits:
-
Float
- Object
- Float
- PhotoUtils::Value
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
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
|
#decr ⇒ Object
23
24
25
|
# File 'lib/photo_utils/value.rb', line 23
def decr
self.class.new_from_v(self.to_v - 1)
end
|
#incr ⇒ Object
19
20
21
|
# File 'lib/photo_utils/value.rb', line 19
def incr
self.class.new_from_v(self.to_v + 1)
end
|
#to_v ⇒ Object
15
16
17
|
# File 'lib/photo_utils/value.rb', line 15
def to_v
raise NotImplementedError, "Subclass has not implemented \#to_v"
end
|