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.



8
9
10
11
# File 'lib/hts/bam/cigar.rb', line 8

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

Instance Method Details

#eachObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/hts/bam/cigar.rb', line 21

def each
  return to_enum(__method__) unless block_given?

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

#to_ptrObject



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

def to_ptr
  @pointer
end

#to_sObject



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

def to_s
  map { |op, len| "#{len}#{op}" }.join
end