Method: File.read_list

Defined in:
lib/mast/core_ext.rb

.read_list(filepath, chomp_string = '') ⇒ Object

Reads in a file, removes blank lines and remarks (lines starting with ‘#’) and then returns an array of all the remaining lines.

CREDIT: Trans


20
21
22
23
24
25
26
27
28
# File 'lib/mast/core_ext.rb', line 20

def self.read_list(filepath, chomp_string='')
  farr = nil
  farr = read(filepath).split("\n")
  farr.collect! { |line|
    l = line.strip.chomp(chomp_string)
    (l.empty? or l[0,1] == '#') ? nil : l
  }
  farr.compact
end