class File_Reader
Constants
- URL_REGEX
Public Class Methods
get_lines(input)
click to toggle source
# File lib/file_reader.rb, line 5 def self.get_lines(input) if input.is_a? Array return input else return File_Reader.get_lines_from_file(input) end end
get_lines_from_file(filename)
click to toggle source
assumes file has one line to one url ratio
# File lib/file_reader.rb, line 14 def self.get_lines_from_file(filename) return null if !filename begin return File.readlines(filename).each_with_object(Array.new) do |line, urls| if( line =~ /#{URL_REGEX}/) urls.push line.chomp end end rescue puts "failed to open file #{filename}" return nil end end