Module: Musa::Datasets::V

Includes:
AbsI
Defined in:
lib/musa-dsl/datasets/v.rb

Constant Summary

Constants included from E

E::NaturalKeys

Instance Method Summary collapse

Methods included from E

#valid?, #validate!

Instance Method Details

#to_packed_V(mapper) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/musa-dsl/datasets/v.rb', line 8

def to_packed_V(mapper)
  case mapper
  when Hash
    pv = {}.extend(PackedV)
    each_index { |i| pv[mapper.keys[i]] = self[i] unless self[i] == mapper.values[i] }
    pv
  when Array
    pv = {}.extend(PackedV)
    each_index { |i| pv[mapper[i]] = self[i] if mapper[i] && self[i] }
    pv
  else
    raise ArgumentError, "Expected Hash or Array as mapper but got a #{mapper.class.name}"
  end
end