Class: Wizard::Spells::MakeDir

Inherits:
Base
  • Object
show all
Defined in:
lib/wizard/spells/make_dir.rb

Constant Summary

Constants included from Helpers

Helpers::COLORS

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @dirname = dirname
  @chmod   = options[:mode]
end

Instance Attribute Details

#chmodObject (readonly)

Returns the value of attribute chmod.



25
26
27
# File 'lib/wizard/spells/make_dir.rb', line 25

def chmod
  @chmod
end

#dirnameObject (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

#performObject



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