Class: Stowaway::FileObj

Inherits:
Object
  • Object
show all
Defined in:
lib/stowaway/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fullpath, root = nil) ⇒ FileObj

Returns a new instance of FileObj.



5
6
7
8
# File 'lib/stowaway/file.rb', line 5

def initialize(fullpath, root = nil)
  @fullpath = fullpath
  @root = root || Dir.pwd
end

Instance Attribute Details

#fullpathObject (readonly)

Returns the value of attribute fullpath.



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

def fullpath
  @fullpath
end

Instance Method Details

#==(fileObj) ⇒ Object



23
24
25
# File 'lib/stowaway/file.rb', line 23

def ==(fileObj)
  self.fullpath == fileObj.fullpath
end

#nameObject



10
11
12
# File 'lib/stowaway/file.rb', line 10

def name
  File.basename(@fullpath)
end

#pathObject



14
15
16
# File 'lib/stowaway/file.rb', line 14

def path
  File.split(@fullpath)[0]
end

#root_pathObject



18
19
20
21
# File 'lib/stowaway/file.rb', line 18

def root_path
  root = @root.split("/").last
  @fullpath.sub(/^.+\/#{root}/, "")
end