Class: Snortor::Rulefile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ Rulefile

Returns a new instance of Rulefile.

Raises:

  • (Errno::ENOENT)


7
8
9
10
11
# File 'lib/rulefile.rb', line 7

def initialize(filepath)
  raise Errno::ENOENT unless File.exists?(filepath)
  @filepath = filepath
  @filename = File.basename(filepath)
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/rulefile.rb', line 3

def filename
  @filename
end

#filepathObject

Returns the value of attribute filepath.



4
5
6
# File 'lib/rulefile.rb', line 4

def filepath
  @filepath
end

#relative_pathObject

Returns the value of attribute relative_path.



5
6
7
# File 'lib/rulefile.rb', line 5

def relative_path
  @relative_path
end

Instance Method Details

#calc_relative_path(fullpath) ⇒ Object



13
14
15
16
17
# File 'lib/rulefile.rb', line 13

def calc_relative_path(fullpath)
  workingdir = fullpath.split("/")
  thispath = @filepath.split("/")
  @relative_path = (thispath-workingdir-[filename]).join("/")
end