Class: VagrantPlugins::AVF::Model::SharedDirectory

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_provider_avf/model/shared_directory.rb

Constant Summary collapse

DEVICE_TAG =
"avfshare".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, host_path:, guest_path:, name: nil) ⇒ SharedDirectory

Returns a new instance of SharedDirectory.



11
12
13
14
15
16
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 11

def initialize(id:, host_path:, guest_path:, name: nil)
  @id = id.to_s
  @host_path = host_path.to_s
  @guest_path = guest_path.to_s
  @name = name || self.class.name_for(id)
end

Instance Attribute Details

#guest_pathObject (readonly)

Returns the value of attribute guest_path.



9
10
11
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 9

def guest_path
  @guest_path
end

#host_pathObject (readonly)

Returns the value of attribute host_path.



9
10
11
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 9

def host_path
  @host_path
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 9

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 9

def name
  @name
end

Class Method Details

.name_for(id) ⇒ Object



26
27
28
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 26

def self.name_for(id)
  "share-#{Digest::SHA256.hexdigest(id.to_s)[0, 12]}"
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
24
# File 'lib/vagrant_provider_avf/model/shared_directory.rb', line 18

def to_h
  {
    "hostPath" => @host_path,
    "name" => @name,
    "readOnly" => false
  }
end