Class: Natives::Catalog::Selector
- Inherits:
-
Object
- Object
- Natives::Catalog::Selector
- Defined in:
- lib/natives/catalog/selector.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ Selector
constructor
A new instance of Selector.
- #values_for(package_provider, platform, platform_version) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Selector
Returns a new instance of Selector.
6 7 8 |
# File 'lib/natives/catalog/selector.rb', line 6 def initialize(hash) @values = normalize(hash) end |
Instance Method Details
#values_for(package_provider, platform, platform_version) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/natives/catalog/selector.rb', line 10 def values_for(package_provider, platform, platform_version) package_provider = package_provider.to_s platform = platform.to_s platform_version = platform_version.to_s values = if @values.key?(package_provider) && @values[package_provider].key?(platform) && @values[package_provider][platform].key?(platform_version) @values[package_provider][platform][platform_version] elsif @values.key?(package_provider) && @values[package_provider].key?(platform) && @values[package_provider][platform].key?('default') @values[package_provider][platform]['default'] elsif @values.key?(package_provider) && @values[package_provider].key?('default') @values[package_provider]['default'] end Array(values) end |