Class: HTS::Bam::Cigar
- Inherits:
-
Object
- Object
- HTS::Bam::Cigar
- Includes:
- Enumerable
- Defined in:
- lib/hts/bam/cigar.rb
Overview
CIGAR string
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(pointer, n_cigar) ⇒ Cigar
constructor
A new instance of Cigar.
- #to_s ⇒ Object
Constructor Details
#initialize(pointer, n_cigar) ⇒ Cigar
Returns a new instance of Cigar.
9 10 11 12 13 14 |
# File 'lib/hts/bam/cigar.rb', line 9 def initialize(pointer, n_cigar) @n_cigar = n_cigar # Read the pointer before the memory is changed. # Especially when called from a block of `each` iterator. @c = pointer.read_array_of_uint32(n_cigar) end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/hts/bam/cigar.rb', line 20 def each return to_enum(__method__) unless block_given? @c.each do |c| op = LibHTS.bam_cigar_opchr(c) len = LibHTS.bam_cigar_oplen(c) yield [op, len] end end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/hts/bam/cigar.rb', line 16 def to_s map { |op, len| "#{len}#{op}" }.join end |