Class: Mingle::MingleNumber
- Inherits:
-
MingleValue
show all
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/mingle.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(num, convert_meth = nil) ⇒ MingleNumber
Returns a new instance of MingleNumber.
140
141
142
143
144
|
# File 'lib/mingle.rb', line 140
def initialize( num, convert_meth = nil )
not_nil( num, :num )
@num = convert_meth ? num.send( convert_meth ) : num
end
|
Instance Attribute Details
#num ⇒ Object
Returns the value of attribute num.
138
139
140
|
# File 'lib/mingle.rb', line 138
def num
@num
end
|
Instance Method Details
#<=>(other) ⇒ Object
165
166
167
168
169
170
171
172
|
# File 'lib/mingle.rb', line 165
def <=>( other )
if other.is_a?( MingleNumber )
@num <=> other.num
else
raise TypeError, other.class.to_s
end
end
|
#==(other) ⇒ Object
Also known as:
eql?
157
158
159
|
# File 'lib/mingle.rb', line 157
def ==( other )
other.class == self.class && other.num == @num
end
|
#inspect ⇒ Object
152
153
154
|
# File 'lib/mingle.rb', line 152
def inspect
to_s.inspect
end
|
#to_f ⇒ Object
180
181
182
|
# File 'lib/mingle.rb', line 180
def to_f
@num.to_f
end
|
#to_i ⇒ Object
175
176
177
|
# File 'lib/mingle.rb', line 175
def to_i
@num.to_i
end
|
#to_s ⇒ Object
147
148
149
|
# File 'lib/mingle.rb', line 147
def to_s
@num.to_s
end
|