Class: Inventory::Authors
- Inherits:
-
Object
- Object
- Inventory::Authors
- Includes:
- Enumerable
- Defined in:
- lib/inventory-1.0/authors.rb
Overview
Contains zero or more authors of the project. Authors can be added and enumerated. Authors are set up by passing a block to #initialize and calling #author inside it.
Instance Method Summary collapse
-
#+(other) ⇒ Authors
The authors of the receiver and those of OTHER.
- #each ⇒ Object
-
#initialize(*authors) {|?| ... } ⇒ Authors
constructor
Creates a new list of AUTHORS and allows more to be added in the optionally #instance_exec’d block by calling #author inside it.
Constructor Details
#initialize(*authors) {|?| ... } ⇒ Authors
Creates a new list of AUTHORS and allows more to be added in the optionally #instance_exec’d block by calling #author inside it.
20 21 22 23 |
# File 'lib/inventory-1.0/authors.rb', line 20 def initialize(*) @authors = instance_exec(&Proc.new) if block_given? end |
Instance Method Details
#+(other) ⇒ Authors
Returns The authors of the receiver and those of OTHER.
40 41 42 |
# File 'lib/inventory-1.0/authors.rb', line 40 def +(other) self.class.new(*( + other.)) end |
# {|author| ... } ⇒ Object # ⇒ Enumerator<Author>
50 51 52 53 54 55 56 |
# File 'lib/inventory-1.0/authors.rb', line 50 def each return enum_for(__method__) unless block_given? .each do || yield end self end |