Class: OptionScrapper::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/optionscrapper/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Batch

Returns a new instance of Batch.

Yields:

  • (_self)

Yield Parameters:



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

#cursorObject

Returns the value of attribute cursor.



9
10
11
# File 'lib/optionscrapper/batch.rb', line 9

def cursor
  @cursor
end

#previousObject

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

#batchesObject

Raises:

  • (StandardError)


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