class Parsefiles::FileOps
Attributes
file[RW]
pattern[RW]
Public Class Methods
new(file,pattern)
click to toggle source
# File lib/parsefiles/file_ops.rb, line 10 def initialize(file,pattern) @file = file @pattern = pattern end
Public Instance Methods
encode_string(input)
click to toggle source
# File lib/parsefiles/file_ops.rb, line 29 def encode_string(input) encode_it(input) end
get_file_type()
click to toggle source
# File lib/parsefiles/file_ops.rb, line 15 def get_file_type File.extname(@file).gsub!(/\./,'') end
match_line(line)
click to toggle source
# File lib/parsefiles/file_ops.rb, line 24 def match_line(line) line = encode_string(line) p line if line.match(@pattern) end
parse_file()
click to toggle source
# File lib/parsefiles/file_ops.rb, line 19 def parse_file method_name = "parse_#{get_file_type}" self.send method_name.to_sym end
Private Instance Methods
encode_it(input)
click to toggle source
# File lib/parsefiles/file_ops.rb, line 35 def encode_it(input) input.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace, :replace => '').encode('UTF-8') end