Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/file.rb

Instance Method Summary collapse

Instance Method Details

#each_except_comments(comment_char = "#") ⇒ Object



3
4
5
6
7
# File 'lib/file.rb', line 3

def each_except_comments(comment_char="#")
  self.each do |line|
     yield line unless line =~ /^#{comment_char}/
  end
end

#list_of_things_in_column(col = 0, sep = "\t", comment_char = "#") ⇒ Object



9
10
11
12
13
14
15
# File 'lib/file.rb', line 9

def list_of_things_in_column(col=0,sep="\t",comment_char="#")
  things = {}
  self.each_except_comments(comment_char) do |line|
    things[ line.split(/#{sep}/)[col] ] = true
  end
  things.keys
end