Class: Altria::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/altria/workspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Workspace

Returns a new instance of Workspace.



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

def initialize(path)
  @path = Pathname.new(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#chdirObject



9
10
11
12
# File 'lib/altria/workspace.rb', line 9

def chdir
  mkpath_unless_exist
  Dir.chdir(path) { yield }
end

#exist?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/altria/workspace.rb', line 22

def exist?
  path.exist?
end

#mkpathObject



18
19
20
# File 'lib/altria/workspace.rb', line 18

def mkpath
  path.mkpath
end

#mkpath_unless_existObject



14
15
16
# File 'lib/altria/workspace.rb', line 14

def mkpath_unless_exist
   mkpath unless exist?
end