Class: Inventory::Licenses
- Inherits:
-
Object
- Object
- Inventory::Licenses
- Includes:
- Enumerable
- Defined in:
- lib/inventory-1.0/licenses.rb
Overview
Contains zero or more licenses of the project. Licenses can be added and enumerated. Licenses are set up by passing a block to #initialize and calling #license inside it.
Instance Method Summary collapse
-
#+(other) ⇒ Licenses
The authors of the receiver and those of OTHER.
- #each ⇒ Object
-
#initialize(*licenses) {|?| ... } ⇒ Licenses
constructor
Creates a new list of LICENSES and allows more to be added in the optionally #instance_exec’d block by calling #license inside it.
Constructor Details
#initialize(*licenses) {|?| ... } ⇒ Licenses
Creates a new list of LICENSES and allows more to be added in the optionally #instance_exec’d block by calling #license inside it.
24 25 26 27 |
# File 'lib/inventory-1.0/licenses.rb', line 24 def initialize(*licenses) @licenses = licenses instance_exec(&Proc.new) if block_given? end |
Instance Method Details
#+(other) ⇒ Licenses
Returns The authors of the receiver and those of OTHER.
44 45 46 |
# File 'lib/inventory-1.0/licenses.rb', line 44 def +(other) self.class.new(*(licenses + other.licenses)) end |
# {|license| ... } ⇒ Object # ⇒ Enumerator<Author>
54 55 56 57 58 59 60 |
# File 'lib/inventory-1.0/licenses.rb', line 54 def each return enum_for(__method__) unless block_given? licenses.each do |license| yield license end self end |