Class: NBTFile::Types::Private::BaseFloat

Inherits:
BaseScalar
  • Object
show all
Defined in:
lib/nbtfile.rb

Instance Attribute Summary

Attributes inherited from BaseScalar

#value

Instance Method Summary collapse

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

Returns:

  • (Boolean)


847
848
849
# File 'lib/nbtfile.rb', line 847

def eql?(other)
  other.class == self.class and other.value == @value
end

#hashObject



851
852
853
# File 'lib/nbtfile.rb', line 851

def hash
  [self.class, @value].hash
end