Class: GFA::Field::NumArray

Inherits:
GFA::Field show all
Defined in:
lib/gfa/field/numarray.rb

Constant Summary collapse

CODE =
:B
REGEX =
/^[cCsSiIf](,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+$/

Constants inherited from GFA::Field

CODES, TYPES

Instance Attribute Summary

Attributes inherited from GFA::Field

#value

Instance Method Summary collapse

Methods inherited from GFA::Field

#code, code_class, #hash, name_class, #regex, #to_s, #type

Constructor Details

#initialize(f) ⇒ NumArray

Returns a new instance of NumArray.



5
6
7
8
# File 'lib/gfa/field/numarray.rb', line 5

def initialize(f)
  GFA.assert_format(f, regex, "Bad #{type}")
  @value = f
end

Instance Method Details

#arrayObject Also known as: as_a



12
# File 'lib/gfa/field/numarray.rb', line 12

def array ; value[2..-1].split(/,/) ; end

#modifierObject



10
# File 'lib/gfa/field/numarray.rb', line 10

def modifier ; value[0] ; end

#number_typeObject



16
17
18
19
20
21
22
23
# File 'lib/gfa/field/numarray.rb', line 16

def number_type
  {
    c: 'int8_t',   C: 'uint8_t',
    s: 'int16_t',  S: 'uint16_t',
    i: 'int32_t',  I: 'uint32_t',
    f: 'float'
  }[modifier.to_sym]
end