Module: Tins::GO::EnumerableExtension
- Includes:
- Enumerable
- Defined in:
- lib/tins/go.rb
Overview
An extension module that provides Enumerable behavior for collecting multiple values associated with the same command-line option.
This extension enables command-line flags like ‘-f foo -f bar` to be collected into a single collection that can be queried via #to_a or #each.
Instance Method Summary collapse
-
#each {|element| ... } ⇒ self
Iterates over each element in the collection.
-
#push(argument) ⇒ self
(also: #<<)
Adds an element to the collection.
Instance Method Details
#each {|element| ... } ⇒ self
Iterates over each element in the collection.
Implements the Enumerable interface, allowing the use of all Enumerable methods like map, select, find, etc.
52 53 54 55 |
# File 'lib/tins/go.rb', line 52 def each(&block) @arguments.each(&block) self end |
#push(argument) ⇒ self Also known as: <<
Adds an element to the collection.
This method allows for chaining operations and collects multiple values for the same command-line option.
31 32 33 34 35 |
# File 'lib/tins/go.rb', line 31 def push(argument) @arguments ||= [] @arguments.push argument self end |