Class: HTS::Bam::Mpileup::DepthView
- Inherits:
-
Object
- Object
- HTS::Bam::Mpileup::DepthView
- Includes:
- Enumerable
- Defined in:
- lib/hts/bam/mpileup.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
(also: #size)
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ DepthView
constructor
A new instance of DepthView.
- #reset(values) ⇒ Object
Constructor Details
#initialize ⇒ DepthView
Returns a new instance of DepthView.
12 |
# File 'lib/hts/bam/mpileup.rb', line 12 def initialize = reset([]) |
Instance Attribute Details
#length ⇒ Object (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
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 |