Class: PgVerify::Model::AllocationSet

Inherits:
Object
  • Object
show all
Defined in:
lib/pg-verify/model/allocation_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables, allocations) ⇒ AllocationSet

Returns a new instance of AllocationSet.



14
15
16
17
18
19
# File 'lib/pg-verify/model/allocation_set.rb', line 14

def initialize(variables, allocations)
    if !allocations.empty? && variables.length != allocations.first.length
        raise "Variables and allocations must match in length!" 
    end
    @variables, @allocations = variables, allocations
end

Instance Attribute Details

#allocationsObject

An array of allocations for those variables. Each allocation is a an array like [0, 1] where indices match the variable array to represent values for that variable



12
13
14
# File 'lib/pg-verify/model/allocation_set.rb', line 12

def allocations
  @allocations
end

#variablesObject

An array of variables



7
8
9
# File 'lib/pg-verify/model/allocation_set.rb', line 7

def variables
  @variables
end

Instance Method Details

#lengthObject



21
22
23
# File 'lib/pg-verify/model/allocation_set.rb', line 21

def length()
    allocations.length
end