Class: Vagrant::BoxMetadata::Version
- Inherits:
-
Object
- Object
- Vagrant::BoxMetadata::Version
- Defined in:
- lib/vagrant/box_metadata.rb
Overview
Represents a single version within the metadata.
Instance Attribute Summary collapse
-
#version ⇒ String
The version that this Version object represents.
Instance Method Summary collapse
-
#initialize(raw = nil) ⇒ Version
constructor
A new instance of Version.
-
#provider(name) ⇒ Object
Returns a [Provider] for the given name, or nil if it isn't supported by this version.
-
#providers ⇒ Array<Symbol>
Returns the providers that are available for this version of the box.
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
#version ⇒ String
The version that this Version object represents.
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 |
#providers ⇒ Array<Symbol>
Returns the providers that are available for this version of the box.
121 122 123 |
# File 'lib/vagrant/box_metadata.rb', line 121 def providers @provider_map.keys.map(&:to_sym) end |