Class: BioVcf::VcfGenotypeFields
- Inherits:
-
Object
- Object
- BioVcf::VcfGenotypeFields
- Defined in:
- lib/bio-vcf/vcfgenotypefield.rb
Overview
Holds all samples
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(fields, format, header, alt) ⇒ VcfGenotypeFields
constructor
A new instance of VcfGenotypeFields.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(fields, format, header, alt) ⇒ VcfGenotypeFields
Returns a new instance of VcfGenotypeFields.
131 132 133 134 135 136 137 138 139 |
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 131 def initialize fields, format, header, alt @fields = fields @format = format @header = header @alt = alt @samples = {} # lazy cache @index = {} @header.samples.each_with_index { |k,i| @index[k] = i+9 ; @index[k.downcase] = i+9 } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
145 146 147 148 |
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 145 def method_missing(m, *args, &block) name = m.to_s @samples[name] ||= VcfGenotypeField.new(@fields[@index[name]],@format,@header,@alt) end |
Instance Method Details
#[](name) ⇒ Object
141 142 143 |
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 141 def [] name @samples[name] ||= VcfGenotypeField.new(@fields[@index[name]],@format,@header,@alt) end |