Class: HTS::Bam::Mpileup::DepthView

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDepthView

Returns a new instance of DepthView.



12
# File 'lib/hts/bam/mpileup.rb', line 12

def initialize = reset([])

Instance Attribute Details

#lengthObject (readonly) Also known as: size

Returns the value of attribute length.



10
11
12
# File 'lib/hts/bam/mpileup.rb', line 10

def length
  @length
end

Instance Method Details

#[](index) ⇒ Object

Raises:

  • (IndexError)


20
21
22
23
24
25
26
# File 'lib/hts/bam/mpileup.rb', line 20

def [](index)
  index = Integer(index)
  index += @length if index.negative?
  raise IndexError, "depth index #{index} outside of view" unless index.between?(0, @length - 1)

  @values[index]
end

#each(&block) ⇒ Object



28
29
30
31
32
33
# File 'lib/hts/bam/mpileup.rb', line 28

def each(&block)
  return to_enum(__method__) unless block_given?

  @values.each(&block)
  self
end

#reset(values) ⇒ Object



14
15
16
17
18
# File 'lib/hts/bam/mpileup.rb', line 14

def reset(values)
  @values = values
  @length = values.length
  self
end