Class: InspectArrayIO

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

Class Method Summary collapse

Class Method Details

.inspect(aio, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/inspect_array_io.rb', line 6

def inspect(aio, options={})
  options = {
    :from_start => 100,
    :from_end => 100}.merge(options)

  puts "N indexed entries: #{aio.length}"

  puts "****************************"
  puts "First #{options[:from_start]} bytes:"
  aio.io.pos = 0
  pp aio.io.read(options[:from_start])
  puts "First entry:"
  puts aio[0]
  
  puts "****************************"
  puts "Last #{options[:from_end]} bytes:"
  aio.io.seek(-options[:from_end], IO::SEEK_END)
  pp aio.io.read(options[:from_end] + 10)
  puts "Last entry:"
  puts aio[-1]
end