Class: MaxMind::DB::MemoryReader
- Inherits:
-
Object
- Object
- MaxMind::DB::MemoryReader
- Defined in:
- lib/maxmind/db/memory_reader.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(filename, options = {}) ⇒ MemoryReader
constructor
A new instance of MemoryReader.
-
#inspect ⇒ Object
Override to not show @buf in inspect to avoid showing it in irb.
- #read(offset, size) ⇒ Object
Constructor Details
#initialize(filename, options = {}) ⇒ MemoryReader
Returns a new instance of MemoryReader.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/maxmind/db/memory_reader.rb', line 6 def initialize(filename, = {}) if [:is_buffer] @buf = filename @size = @buf.length return end @buf = File.read(filename, mode: 'rb').freeze @size = @buf.length end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
17 18 19 |
# File 'lib/maxmind/db/memory_reader.rb', line 17 def size @size end |
Instance Method Details
#close ⇒ Object
25 |
# File 'lib/maxmind/db/memory_reader.rb', line 25 def close; end |
#inspect ⇒ Object
Override to not show @buf in inspect to avoid showing it in irb.
20 21 22 23 |
# File 'lib/maxmind/db/memory_reader.rb', line 20 def inspect s = "#<#{self.class.name}:0x#{self.class.object_id.to_s(16)} " s << '@size=' << @size.inspect << '>' end |
#read(offset, size) ⇒ Object
27 28 29 |
# File 'lib/maxmind/db/memory_reader.rb', line 27 def read(offset, size) @buf[offset, size] end |