Method: BitStruct::Vector#initialize
- Defined in:
- lib/bit-struct/vector.rb
#initialize(arg) {|_self| ... } ⇒ Vector
arg can be an integer (number of entries) or a string (binary data, such as another Vector of the same size).
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/bit-struct/vector.rb', line 99 def initialize arg # :yields: instance case arg when Integer super(struct_class.initial_value * arg) else begin super arg rescue NameError raise ArgumentError, "must be string or integer: #{arg.inspect}" end end yield self if block_given? end |