Class: OptionScrapper::Batch
- Inherits:
-
Object
- Object
- OptionScrapper::Batch
- Defined in:
- lib/optionscrapper/batch.rb
Instance Attribute Summary collapse
-
#cursor ⇒ Object
Returns the value of attribute cursor.
-
#previous ⇒ Object
Returns the value of attribute previous.
Instance Method Summary collapse
- #add(argument) ⇒ Object
- #batches ⇒ Object
- #global(argument) ⇒ Object
-
#initialize {|_self| ... } ⇒ Batch
constructor
A new instance of Batch.
Constructor Details
#initialize {|_self| ... } ⇒ Batch
Returns a new instance of Batch.
11 12 13 14 15 16 |
# File 'lib/optionscrapper/batch.rb', line 11 def initialize @cursor = OptionScrapper::OptionsParser::GLOBAL_PARSER @batches = { OptionScrapper::OptionsParser::GLOBAL_PARSER => [] } @previous = nil yield self if block_given? end |
Instance Attribute Details
#cursor ⇒ Object
Returns the value of attribute cursor.
9 10 11 |
# File 'lib/optionscrapper/batch.rb', line 9 def cursor @cursor end |
#previous ⇒ Object
Returns the value of attribute previous.
9 10 11 |
# File 'lib/optionscrapper/batch.rb', line 9 def previous @previous end |
Instance Method Details
#add(argument) ⇒ Object
25 26 27 28 29 |
# File 'lib/optionscrapper/batch.rb', line 25 def add(argument) @previous = nil @batches[@cursor] ||= [] @batches[@cursor] << argument end |
#batches ⇒ Object
18 19 20 21 22 23 |
# File 'lib/optionscrapper/batch.rb', line 18 def batches raise StandardError, 'batches: you have not supplied a block to call' unless block_given? @batches.each_pair do |name,arguments| yield name,arguments end end |
#global(argument) ⇒ Object
31 32 33 |
# File 'lib/optionscrapper/batch.rb', line 31 def global(argument) @batches[OptionScrapper::OptionsParser::GLOBAL_PARSER] << argument end |