Class: Pbmenv::DestroyVersionService

Inherits:
Object
  • Object
show all
Defined in:
lib/pbmenv/services/destroy_version_service.rb

Defined Under Namespace

Classes: VersionNotFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version:) ⇒ DestroyVersionService

Returns a new instance of DestroyVersionService.



9
10
11
# File 'lib/pbmenv/services/destroy_version_service.rb', line 9

def initialize(version: )
  @version = version
end

Instance Attribute Details

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/pbmenv/services/destroy_version_service.rb', line 7

def version
  @version
end

Instance Method Details

#execute!Object



13
14
15
16
17
18
19
20
# File 'lib/pbmenv/services/destroy_version_service.rb', line 13

def execute!
  version_pathname = VersionPathname.new(version)

  unless File.exist?(version_pathname.version_path)
    raise VersionNotFoundError
  end
  Helper.system_and_puts "rm -rf #{version_pathname.version_path}"
end