Class: NBTFile::Types::Private::BaseFloat
- Inherits:
-
BaseScalar
- Object
- BaseScalar
- NBTFile::Types::Private::BaseFloat
- Defined in:
- lib/nbtfile.rb
Instance Attribute Summary
Attributes inherited from BaseScalar
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(value) ⇒ BaseFloat
constructor
A new instance of BaseFloat.
Methods inherited from BaseScalar
Constructor Details
#initialize(value) ⇒ BaseFloat
Returns a new instance of BaseFloat.
831 832 833 834 835 836 837 |
# File 'lib/nbtfile.rb', line 831 def initialize(value) unless Numeric === value raise TypeError end float_value = value.to_f @value = float_value end |
Instance Method Details
#==(other) ⇒ Object
839 840 841 842 843 844 845 |
# File 'lib/nbtfile.rb', line 839 def ==(other) if Numeric === other or BaseFloat === other @value == other.to_f else false end end |
#eql?(other) ⇒ Boolean
847 848 849 |
# File 'lib/nbtfile.rb', line 847 def eql?(other) other.class == self.class and other.value == @value end |
#hash ⇒ Object
851 852 853 |
# File 'lib/nbtfile.rb', line 851 def hash [self.class, @value].hash end |