Class: BareTypes::Data

Inherits:
BarePrimitive show all
Defined in:
lib/types.rb,
lib/generative_testing/monkey_patch.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BarePrimitive

#==, #to_schema

Methods inherited from BaseType

#cycle_search, #initialize

Constructor Details

This class inherits a constructor from BareTypes::BaseType

Class Method Details

.make(depth, names) ⇒ Object



163
164
165
# File 'lib/generative_testing/monkey_patch.rb', line 163

def self.make(depth, names)
  self.new
end

Instance Method Details

#create_inputObject



167
168
169
170
171
172
173
# File 'lib/generative_testing/monkey_patch.rb', line 167

def create_input
  arr = []
  0.upto(rand(DATA_MAX_SIZE)).each do |i|
    arr << i % 256
  end
  arr.pack('c*')
end

#decode(msg) ⇒ Object



258
259
260
261
# File 'lib/types.rb', line 258

def decode(msg)
  dataSize, rest = Uint.new.decode(msg)
  return rest[0..dataSize - 1], rest[dataSize..rest.size]
end

#encode(msg, buffer) ⇒ Object



253
254
255
256
# File 'lib/types.rb', line 253

def encode(msg, buffer)
  Uint.new.encode(msg.size, buffer)
  buffer << msg
end

#finalize_references(schema) ⇒ Object



251
# File 'lib/types.rb', line 251

def finalize_references(schema) end