Class: Warbler::Gems
- Inherits:
-
Hash
- Object
- Hash
- Warbler::Gems
- Defined in:
- lib/warbler/gems.rb
Overview
A set of gems. This only exists to allow expected operations to be used to add gems, and for backwards compatibility. It would be easier to just use a hash.
Constant Summary collapse
- ANY_VERSION =
nil
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<<(gem) ⇒ Object
-
#initialize(gems = nil) ⇒ Gems
constructor
A new instance of Gems.
Constructor Details
#initialize(gems = nil) ⇒ Gems
Returns a new instance of Gems.
14 15 16 17 18 19 20 |
# File 'lib/warbler/gems.rb', line 14 def initialize(gems = nil) if gems.is_a?(Hash) self.merge!(gems) elsif gems.is_a?(Array) gems.each {|gem| self << gem } end end |
Instance Method Details
#+(other) ⇒ Object
26 27 28 29 |
# File 'lib/warbler/gems.rb', line 26 def +(other) other.each {|g| self[g] ||= ANY_VERSION } self end |
#-(other) ⇒ Object
31 32 33 34 |
# File 'lib/warbler/gems.rb', line 31 def -(other) other.each {|g| self.delete(g)} self end |
#<<(gem) ⇒ Object
22 23 24 |
# File 'lib/warbler/gems.rb', line 22 def <<(gem) self[gem] ||= ANY_VERSION end |