Class: Tresse::Batch

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group, block_or_group) ⇒ Batch

Returns a new instance of Batch.



86
87
88
89
90
91
92
93
94
# File 'lib/tresse.rb', line 86

def initialize(group, block_or_group)

  @group = group
  @bog = block_or_group

  @map_index = -1
  @value = nil
  @completed = false
end

Instance Attribute Details

#completedObject (readonly)

Returns the value of attribute completed.



82
83
84
# File 'lib/tresse.rb', line 82

def completed
  @completed
end

#errorObject

Returns the value of attribute error.



84
85
86
# File 'lib/tresse.rb', line 84

def error
  @error
end

#groupObject (readonly)

Returns the value of attribute group.



80
81
82
# File 'lib/tresse.rb', line 80

def group
  @group
end

#map_indexObject (readonly)

Returns the value of attribute map_index.



81
82
83
# File 'lib/tresse.rb', line 81

def map_index
  @map_index
end

#valueObject

Returns the value of attribute value.



83
84
85
# File 'lib/tresse.rb', line 83

def value
  @value
end

Instance Method Details

#completeObject



114
115
116
117
# File 'lib/tresse.rb', line 114

def complete

  @completed = true
end

#map(type, block) ⇒ Object



107
108
109
110
111
112
# File 'lib/tresse.rb', line 107

def map(type, block)

  r = Tresse.call_block(block, [ @value, self ])

  @value = r if type == :map
end

#processObject



96
97
98
99
100
# File 'lib/tresse.rb', line 96

def process

  @map_index += 1
  @group.send(:receive, self)
end

#sourceObject



102
103
104
105
# File 'lib/tresse.rb', line 102

def source

  @value = Tresse.call_block(@bog, [ group ] + [ nil ] * 7)
end