Class: Parsefiles::FileOps

Inherits:
Object
  • Object
show all
Includes:
Parse
Defined in:
lib/parsefiles/file_ops.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parse

#parse_gz, #parse_log, #parse_zip

Constructor Details

#initialize(file, pattern) ⇒ FileOps

Returns a new instance of FileOps.



10
11
12
13
# File 'lib/parsefiles/file_ops.rb', line 10

def initialize(file,pattern)
  @file = file
  @pattern = pattern
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



8
9
10
# File 'lib/parsefiles/file_ops.rb', line 8

def file
  @file
end

#patternObject

Returns the value of attribute pattern.



8
9
10
# File 'lib/parsefiles/file_ops.rb', line 8

def pattern
  @pattern
end

Instance Method Details

#encode_string(input) ⇒ Object



29
30
31
# File 'lib/parsefiles/file_ops.rb', line 29

def encode_string(input)
  encode_it(input)
end

#get_file_typeObject



15
16
17
# File 'lib/parsefiles/file_ops.rb', line 15

def get_file_type
  File.extname(@file).gsub!(/\./,'')
end

#match_line(line) ⇒ Object



24
25
26
27
# File 'lib/parsefiles/file_ops.rb', line 24

def match_line(line)
  line = encode_string(line)
  p line if line.match(@pattern)
end

#parse_fileObject



19
20
21
22
# File 'lib/parsefiles/file_ops.rb', line 19

def parse_file
  method_name = "parse_#{get_file_type}"
  self.send method_name.to_sym
end