Class: Flagstat
- Inherits:
-
Object
show all
- Defined in:
- lib/germ/flagstat.rb
Instance Method Summary
collapse
Constructor Details
#initialize(file) ⇒ Flagstat
Returns a new instance of Flagstat.
2
3
4
5
6
7
8
|
# File 'lib/germ/flagstat.rb', line 2
def initialize file
@headers = [ :total, :duplicates, :mapped, :paired_in_sequence, :read1, :read2,
:properly_paired, :both_mapped, :singletons, :mate_mapped_chr, :mate_mapped_chr_highq ]
@flags = Hash[@headers.zip(File.foreach(file).each_with_index.map do |l|
l.scan(/([0-9]+) \+ ([0-9]+)/).flatten
end)]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/germ/flagstat.rb', line 20
def method_missing(method, *args, &block)
return @flags[method].first.to_i if @flags[method]
method.to_s.match(/^chastity_(.*)/) do |m|
return @flags[m[1].to_sym].last.to_i if @flags[m[1].to_sym]
end
super
end
|
Instance Method Details
#each ⇒ Object
10
11
12
13
14
|
# File 'lib/germ/flagstat.rb', line 10
def each
@flags.each do |f,l|
yield f,l
end
end
|
#respond_to_missing?(sym, include_all = false) ⇒ Boolean
16
17
18
|
# File 'lib/germ/flagstat.rb', line 16
def respond_to_missing? sym, include_all = false
@flags[sym] || sym.to_s =~ /^chastity_/ || super
end
|