Class: Nanite::FileChunk

Inherits:
Packet show all
Defined in:
lib/nanite/packets.rb

Overview

packet that carries data chunks during a file transfer

Instance Attribute Summary collapse

Attributes inherited from Packet

#size

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

#id_to_s, #to_json

Constructor Details

#initialize(token, size = nil, chunk = nil) ⇒ FileChunk

Returns a new instance of FileChunk.



92
93
94
95
96
# File 'lib/nanite/packets.rb', line 92

def initialize(token, size=nil, chunk=nil)
  @chunk = chunk
  @token = token
  @size = size
end

Instance Attribute Details

#chunkObject

Returns the value of attribute chunk.



90
91
92
# File 'lib/nanite/packets.rb', line 90

def chunk
  @chunk
end

#tokenObject

Returns the value of attribute token.



90
91
92
# File 'lib/nanite/packets.rb', line 90

def token
  @token
end

Class Method Details

.json_create(o) ⇒ Object



98
99
100
101
# File 'lib/nanite/packets.rb', line 98

def self.json_create(o)
  i = o['data']
  new(i['token'], o['size'], i['chunk'])
end

Instance Method Details

#to_sObject



103
104
105
# File 'lib/nanite/packets.rb', line 103

def to_s
  "#{super} <#{token}>"
end