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.


99
100
101
102
103
104
105
106
107
# File 'lib/vagrant/box_metadata.rb', line 99

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)

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

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.


111
112
113
114
115
# File 'lib/vagrant/box_metadata.rb', line 111

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>)

121
122
123
# File 'lib/vagrant/box_metadata.rb', line 121

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