Class: Fuckery::Commands::Delete

Inherits:
Object
  • Object
show all
Defined in:
lib/fuckery/commands/delete.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Delete

Returns a new instance of Delete.



6
7
8
# File 'lib/fuckery/commands/delete.rb', line 6

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/fuckery/commands/delete.rb', line 4

def name
  @name
end

Instance Method Details

#directoryObject



22
23
24
# File 'lib/fuckery/commands/delete.rb', line 22

def directory
  Fuckery.fuckery_directory(name)
end

#directory_exists?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/fuckery/commands/delete.rb', line 18

def directory_exists?
  Dir.exists? directory
end

#executeObject



10
11
12
13
14
15
16
# File 'lib/fuckery/commands/delete.rb', line 10

def execute
  if directory_exists?
    FileUtils.rm_rf directory
  else
    raise DoesNotExistError.new("#{name.inspect} is not currently a fuckery (check your spelling)")
  end
end