Class: Nitro::OvtBin
Instance Attribute Summary collapse
-
#entry_count ⇒ Object
readonly
Returns the value of attribute entry_count.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #get_entry(id) ⇒ Object
-
#initialize(args = {}) ⇒ OvtBin
constructor
A new instance of OvtBin.
Constructor Details
#initialize(args = {}) ⇒ OvtBin
Returns a new instance of OvtBin.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/nitro/nitro.rb', line 115 def initialize(args = {}) if args.has_key? :file_path bin = File.binread(args[:file_path]) @size = bin.bytesize @ptr = FFI::MemoryPointer.new(:uint8, @size) @ptr.put_bytes(0, bin) elsif args.has_key?(:ptr) && args.has_key?(:size) @ptr = args[:ptr] @size = args[:size] @entry_count = @size / OvtEntry.size else raise ArgumentError end end |
Instance Attribute Details
#entry_count ⇒ Object (readonly)
Returns the value of attribute entry_count.
113 114 115 |
# File 'lib/nitro/nitro.rb', line 113 def entry_count @entry_count end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
113 114 115 |
# File 'lib/nitro/nitro.rb', line 113 def size @size end |
Instance Method Details
#get_entry(id) ⇒ Object
131 132 133 134 |
# File 'lib/nitro/nitro.rb', line 131 def get_entry(id) raise IndexError if id > @entry_count-1 OvtEntry.new(@ptr + id*OvtEntry.size) end |