Class: Tresse::Batch
- Inherits:
-
Object
- Object
- Tresse::Batch
- Defined in:
- lib/tresse.rb
Instance Attribute Summary collapse
-
#completed ⇒ Object
readonly
Returns the value of attribute completed.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#map_index ⇒ Object
readonly
Returns the value of attribute map_index.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #complete ⇒ Object
-
#initialize(group, block_or_group) ⇒ Batch
constructor
A new instance of Batch.
- #map(type, block) ⇒ Object
- #process ⇒ Object
- #source ⇒ Object
Constructor Details
#initialize(group, block_or_group) ⇒ Batch
Returns a new instance of Batch.
99 100 101 102 103 104 105 106 107 |
# File 'lib/tresse.rb', line 99 def initialize(group, block_or_group) @group = group @bog = block_or_group @map_index = -1 @value = nil @completed = false end |
Instance Attribute Details
#completed ⇒ Object (readonly)
Returns the value of attribute completed.
96 97 98 |
# File 'lib/tresse.rb', line 96 def completed @completed end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
94 95 96 |
# File 'lib/tresse.rb', line 94 def group @group end |
#map_index ⇒ Object (readonly)
Returns the value of attribute map_index.
95 96 97 |
# File 'lib/tresse.rb', line 95 def map_index @map_index end |
#value ⇒ Object
Returns the value of attribute value.
97 98 99 |
# File 'lib/tresse.rb', line 97 def value @value end |
Instance Method Details
#complete ⇒ Object
127 128 129 130 |
# File 'lib/tresse.rb', line 127 def complete @completed = true end |
#map(type, block) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/tresse.rb', line 120 def map(type, block) r = Tresse.call_block(block, [ @value, self ]) @value = r if type == :map end |
#process ⇒ Object
109 110 111 112 113 |
# File 'lib/tresse.rb', line 109 def process @map_index += 1 @group.send(:receive, self) end |
#source ⇒ Object
115 116 117 118 |
# File 'lib/tresse.rb', line 115 def source @value = Tresse.call_block(@bog, [ group ] + [ nil ] * 7) end |