Class: Natives::Catalog::Selector
- Inherits:
-
Object
- Object
- Natives::Catalog::Selector
- Defined in:
- lib/natives/catalog/selector.rb
Instance Method Summary collapse
-
#initialize(platform_hash) ⇒ Selector
constructor
A new instance of Selector.
- #value_for(platform, platform_version, package_provider) ⇒ Object
Constructor Details
#initialize(platform_hash) ⇒ Selector
Returns a new instance of Selector.
4 5 6 7 |
# File 'lib/natives/catalog/selector.rb', line 4 def initialize(platform_hash) assert_valid_platform_hash(platform_hash) @values = normalize_platform_hash(platform_hash) end |
Instance Method Details
#value_for(platform, platform_version, package_provider) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/natives/catalog/selector.rb', line 9 def value_for(platform, platform_version, package_provider) key = "#{platform.to_s}/#{package_provider.to_s}" if @values.key?(key) && @values[key].key?(platform_version) @values[key][platform_version] elsif @values.key?(key) && @values[key].key?('default') @values[key]['default'] elsif @values.key?('default') @values['default'] else nil end end |