Class: Vagrant::BoxMetadata::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/box_metadata.rb

Overview

Represents a single version within the metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw = nil) ⇒ Version

Returns a new instance of Version.



85
86
87
88
89
90
91
92
93
# File 'lib/vagrant/box_metadata.rb', line 85

def initialize(raw=nil)
  return if !raw

  @version = raw["version"]
  @provider_map = (raw["providers"] || []).map do |p|
    [p["name"].to_sym, p]
  end
  @provider_map = Hash[@provider_map]
end

Instance Attribute Details

#versionString

The version that this Version object represents.

Returns:

  • (String)


83
84
85
# File 'lib/vagrant/box_metadata.rb', line 83

def version
  @version
end

Instance Method Details

#provider(name) ⇒ Object

Returns a [Provider] for the given name, or nil if it isn't supported by this version.



97
98
99
100
101
# File 'lib/vagrant/box_metadata.rb', line 97

def provider(name)
  p = @provider_map[name.to_sym]
  return nil if !p
  Provider.new(p)
end

#providersArray<Symbol>

Returns the providers that are available for this version of the box.

Returns:

  • (Array<Symbol>)


107
108
109
# File 'lib/vagrant/box_metadata.rb', line 107

def providers
  @provider_map.keys.map(&:to_sym)
end