Class: ChunkIO::ChunkIO

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

Instance Method Summary collapse

Constructor Details

#initialize(context_path:, stream_name:) ⇒ ChunkIO

Returns a new instance of ChunkIO.



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

def initialize(context_path:, stream_name:)
  unless context_path
    raise 'invalid'
  end

  unless stream_name
    raise 'stream'
  end

  if  context_path.empty?
    raise 'context_path should be at least one char'
  end

  if stream_name.empty?
    raise 'stream_name should be at least one char'
  end

  @ctx = ::ChunkIO::Context.new(context_path)
  @stream = ::ChunkIO::Stream.new(@ctx, stream_name)
  @chunks = []
end

Instance Method Details

#create_chunk(name:) ⇒ Object



29
30
31
32
33
# File 'lib/chunkio/chunkio.rb', line 29

def create_chunk(name:)
  c = ::ChunkIO::Chunk.new(@ctx, @stream, name)
  @chunks << c
  c
end