Class: Plywood::Commands
- Inherits:
-
Object
- Object
- Plywood::Commands
- Defined in:
- lib/plywood/commands.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(io_handler_class: Logger, sequential: false) {|_self| ... } ⇒ Commands
constructor
A new instance of Commands.
- #register(name, command) ⇒ Object
Constructor Details
#initialize(io_handler_class: Logger, sequential: false) {|_self| ... } ⇒ Commands
Returns a new instance of Commands.
7 8 9 10 11 12 13 |
# File 'lib/plywood/commands.rb', line 7 def initialize(io_handler_class: Logger, sequential: false) @list = {} @io_handler_class = io_handler_class @sequential = sequential yield self run end |
Class Method Details
.map(array, io_handler_class: Logger, id: :to_s, sequential: false) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/plywood/commands.rb', line 15 def self.map(array, io_handler_class: Logger, id: :to_s, sequential: false) new(io_handler_class: io_handler_class, sequential: sequential) do |ply| array.each do |item| command = yield item name = name_for_item(item, id: id) ply.register(name, command) end end end |
Instance Method Details
#register(name, command) ⇒ Object
25 26 27 28 |
# File 'lib/plywood/commands.rb', line 25 def register(name, command) @list[name.to_s] = Command.new(name, command) self end |