Module: WahWah::LazyRead

Included in:
Asf::Object, Flac::Block, ID3::Frame, Mp4::Atom, Riff::Chunk
Defined in:
lib/wahwah/lazy_read.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
# File 'lib/wahwah/lazy_read.rb', line 5

def self.prepended(base)
  base.class_eval do
    attr_reader :size
  end
end

Instance Method Details

#dataObject



17
18
19
20
# File 'lib/wahwah/lazy_read.rb', line 17

def data
  @file_io.seek(@position)
  @file_io.read(size)
end

#initialize(file_io, *arg) ⇒ Object



11
12
13
14
15
# File 'lib/wahwah/lazy_read.rb', line 11

def initialize(file_io, *arg)
  @file_io = file_io
  super(*arg)
  @position = @file_io.pos
end

#skipObject



22
23
24
# File 'lib/wahwah/lazy_read.rb', line 22

def skip
  @file_io.seek(size, IO::SEEK_CUR)
end