Class: HTS::Bam::Cigar

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hts/bam/cigar.rb

Instance Method Summary collapse

Constructor Details

#initialize(pointer, n_cigar) ⇒ Cigar

Returns a new instance of Cigar.



11
12
13
14
# File 'lib/hts/bam/cigar.rb', line 11

def initialize(pointer, n_cigar)
  @pointer = pointer
  @n_cigar = n_cigar
end

Instance Method Details

#eachObject



24
25
26
27
28
29
30
31
32
# File 'lib/hts/bam/cigar.rb', line 24

def each
  return to_enum(__method__) unless block_given?

  @n_cigar.times do |i|
    c = @pointer[i].read_uint32
    yield [LibHTS.bam_cigar_oplen(c),
           LibHTS.bam_cigar_opchr(c)]
  end
end

#to_ptrObject



16
17
18
# File 'lib/hts/bam/cigar.rb', line 16

def to_ptr
  @pointer
end

#to_sObject



20
21
22
# File 'lib/hts/bam/cigar.rb', line 20

def to_s
  to_a.flatten.join
end