Class: Magi::Workspace
- Inherits:
-
Object
- Object
- Magi::Workspace
- Defined in:
- lib/magi/workspace.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #chdir ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(path) ⇒ Workspace
constructor
A new instance of Workspace.
- #mkpath ⇒ Object
- #mkpath_unless_exist ⇒ Object
Constructor Details
#initialize(path) ⇒ Workspace
Returns a new instance of Workspace.
5 6 7 |
# File 'lib/magi/workspace.rb', line 5 def initialize(path) @path = Pathname.new(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/magi/workspace.rb', line 3 def path @path end |
Instance Method Details
#chdir ⇒ Object
9 10 11 12 |
# File 'lib/magi/workspace.rb', line 9 def chdir mkpath_unless_exist Dir.chdir(path) { yield } end |
#exist? ⇒ Boolean
22 23 24 |
# File 'lib/magi/workspace.rb', line 22 def exist? path.exist? end |
#mkpath ⇒ Object
18 19 20 |
# File 'lib/magi/workspace.rb', line 18 def mkpath path.mkpath end |
#mkpath_unless_exist ⇒ Object
14 15 16 |
# File 'lib/magi/workspace.rb', line 14 def mkpath_unless_exist mkpath unless exist? end |