Class: YandexDisk::Chunked

Inherits:
Object show all
Defined in:
lib/yandex_disk/chunked.rb

Instance Method Summary collapse

Constructor Details

#initialize(data, chunk_size) ⇒ Chunked

Returns a new instance of Chunked.



4
5
6
7
8
9
# File 'lib/yandex_disk/chunked.rb', line 4

def initialize(data, chunk_size)
  @size = chunk_size
  if data.respond_to? :read
    @file = data
  end
end

Instance Method Details

#eof!Object



21
22
23
# File 'lib/yandex_disk/chunked.rb', line 21

def eof!
  @file.eof!
end

#eof?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/yandex_disk/chunked.rb', line 25

def eof?
  @file.eof?
end

#read(a, b = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/yandex_disk/chunked.rb', line 11

def read(a, b = nil)
  if @file
    if b
      @file.read(@size, b)
    else
      @file.read(@size)
    end
  end
end