Class: Morion::FileRef

Inherits:
Object
  • Object
show all
Defined in:
lib/morion/file_ref.rb

Constant Summary collapse

FILENAME_REGEX =
%r{(?:.+/)([^#?]+)}.freeze
EXTENSION_REGEX =
/\.[^.]*$/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, current_path) ⇒ FileRef

Returns a new instance of FileRef.



8
9
10
11
12
13
14
15
# File 'lib/morion/file_ref.rb', line 8

def initialize(path, current_path)
  @path = path
  @current_path = current_path
  @filename = @path.match(FILENAME_REGEX)[1]
  @extension = filename.match(EXTENSION_REGEX)[0]
  @relative_path = @path.gsub(@current_path, '')
  @folder_path = @relative_path.match(%r{(.*)/.*})[1]
end

Instance Attribute Details

#extensionObject

Returns the value of attribute extension.



6
7
8
# File 'lib/morion/file_ref.rb', line 6

def extension
  @extension
end

#filenameObject

Returns the value of attribute filename.



6
7
8
# File 'lib/morion/file_ref.rb', line 6

def filename
  @filename
end

#folder_pathObject

Returns the value of attribute folder_path.



6
7
8
# File 'lib/morion/file_ref.rb', line 6

def folder_path
  @folder_path
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/morion/file_ref.rb', line 6

def path
  @path
end

#relative_pathObject

Returns the value of attribute relative_path.



6
7
8
# File 'lib/morion/file_ref.rb', line 6

def relative_path
  @relative_path
end