Class: Wizard::Spells::MakeDir
- Defined in:
- lib/wizard/spells/make_dir.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#chmod ⇒ Object
readonly
Returns the value of attribute chmod.
-
#dirname ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute dirname.
Instance Method Summary collapse
-
#initialize(dirname, options = {}) ⇒ MakeDir
constructor
A new instance of MakeDir.
- #perform ⇒ Object
Methods inherited from Base
all_forced?, attr_status, #force!, force_all!, #force_all!, #forced?, #status, #status?
Methods included from Helpers
#adjust, #colorize, #console_width, #print, #say, #say!
Constructor Details
#initialize(dirname, options = {}) ⇒ MakeDir
Returns a new instance of MakeDir.
28 29 30 31 |
# File 'lib/wizard/spells/make_dir.rb', line 28 def initialize(dirname, ={}) @dirname = dirname @chmod = [:mode] end |
Instance Attribute Details
#chmod ⇒ Object (readonly)
Returns the value of attribute chmod.
25 26 27 |
# File 'lib/wizard/spells/make_dir.rb', line 25 def chmod @chmod end |
#dirname ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute dirname.
25 26 27 |
# File 'lib/wizard/spells/make_dir.rb', line 25 def dirname @dirname end |
Instance Method Details
#perform ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/wizard/spells/make_dir.rb', line 33 def perform return exist! if File.exist?(dirname) return created! if FileUtils.mkdir_p(dirname, :mode => chmod) == dirname error! rescue Errno::EACCES noaccess! rescue Object error! end |