Skip to content

Commit

Permalink
Fixed annoying Enumerable issue - now we can drop use of to_a in Ruby…
Browse files Browse the repository at this point in the history
… 1.9+
  • Loading branch information
pjotrp committed Feb 27, 2014
1 parent e8e5e45 commit 22be559
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -211,7 +211,7 @@ gem
gem install statsample gem install statsample
``` ```


(statsample is not loaded by default, as it has a host of (statsample is not loaded by default because it has a host of
dependencies) dependencies)


Thereafter, to calculate the stats for columns 1 and 2 (rowname is column 0) Thereafter, to calculate the stats for columns 1 and 2 (rowname is column 0)
Expand Down
16 changes: 12 additions & 4 deletions lib/bio-table/filter.rb
@@ -1,6 +1,10 @@
module BioTable module BioTable


# LazyValues fetches values on demand from the @fields array. In the [] method
# a field is transformed into a float when it is called.

class LazyValues class LazyValues

include Enumerable include Enumerable


def initialize fields def initialize fields
Expand All @@ -16,12 +20,16 @@ def [] index
@values[index] @values[index]
end end


def each def each &block
@fields.each_with_index do | field, i | @fields.each_with_index do |field,i|
yield self[i] if block_given?
block.call self[i]
else
yield self[i]
end
end end
end end

def compact def compact
a = [] a = []
each do | e | each do | e |
Expand Down
7 changes: 6 additions & 1 deletion lib/bio-table/statistics.rb
Expand Up @@ -3,7 +3,12 @@ module BioTable


module Statistics module Statistics


require 'statsample' begin
require 'statsample'
rescue LoadError
$stderr.print "Error: Missing statsample. Install with command 'gem install statsample'\n"
exit 1
end


attr_reader :columns attr_reader :columns


Expand Down

0 comments on commit 22be559

Please sign in to comment.