Class: Factorix::SerDes::UnsignedInteger
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Factorix::SerDes::UnsignedInteger
- Defined in:
- lib/factorix/ser_des/unsigned_integer.rb
Overview
Unsigned integer wrapper
This class wraps a non-negative Integer value to indicate it was originally stored as an unsigned integer (Type 7) in Factorio’s Property Tree format.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compare with another UnsignedInteger or Integer.
-
#hash ⇒ Integer
Hash code for use in Hash keys.
-
#initialize(value) ⇒ UnsignedInteger
constructor
Create a new UnsignedInteger.
-
#inspect ⇒ String
String representation.
-
#value ⇒ Integer
Get the underlying integer value.
Constructor Details
#initialize(value) ⇒ UnsignedInteger
Create a new UnsignedInteger
24 25 26 27 28 29 |
# File 'lib/factorix/ser_des/unsigned_integer.rb', line 24 def initialize(value) raise ArgumentError, "value must be an Integer" unless value.is_a?(Integer) raise ArgumentError, "value must be non-negative" if value.negative? super end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compare with another UnsignedInteger or Integer
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/factorix/ser_des/unsigned_integer.rb', line 40 def ==(other) case other when UnsignedInteger value == other.value when Integer value == other else false end end |
#hash ⇒ Integer
Hash code for use in Hash keys
54 |
# File 'lib/factorix/ser_des/unsigned_integer.rb', line 54 def hash = [value, :unsigned].hash |
#inspect ⇒ String
String representation
62 |
# File 'lib/factorix/ser_des/unsigned_integer.rb', line 62 def inspect = "#<Factorix::SerDes::UnsignedInteger:0x%016x value=#{value}>" % object_id |
#value ⇒ Integer
Get the underlying integer value
34 |
# File 'lib/factorix/ser_des/unsigned_integer.rb', line 34 def value = __getobj__ |