Class: GodOfThunderSave::IntegerValue
- Inherits:
-
Object
- Object
- GodOfThunderSave::IntegerValue
- Defined in:
- lib/god_of_thunder_save/integer_value.rb
Constant Summary collapse
- INTEGER_DIRECTIVES =
{ 1 => "C", 2 => "v", 4 => "V" }.freeze
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
Instance Method Summary collapse
-
#initialize(pos:, bytes:) ⇒ IntegerValue
constructor
A new instance of IntegerValue.
- #read(file) ⇒ Object
- #write(file, data) ⇒ Object
Constructor Details
#initialize(pos:, bytes:) ⇒ IntegerValue
Returns a new instance of IntegerValue.
13 14 15 16 |
# File 'lib/god_of_thunder_save/integer_value.rb', line 13 def initialize(pos:, bytes:) @pos = pos @bytes = bytes end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
11 12 13 |
# File 'lib/god_of_thunder_save/integer_value.rb', line 11 def bytes @bytes end |
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
11 12 13 |
# File 'lib/god_of_thunder_save/integer_value.rb', line 11 def pos @pos end |
Instance Method Details
#read(file) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/god_of_thunder_save/integer_value.rb', line 18 def read(file) file.seek(pos) bytes_read = file.read(bytes) bytes_read.unpack(integer_directive).first end |
#write(file, data) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/god_of_thunder_save/integer_value.rb', line 25 def write(file, data) bytes_write = [data].pack(integer_directive) file.seek(pos) file.write(bytes_write) end |