Class: Ralph
- Inherits:
-
Object
show all
- Defined in:
- lib/ralph.rb,
lib/iterator.rb
Defined Under Namespace
Modules: Iterator
Classes: Job
Constant Summary
collapse
- VERSION =
'0.1.0'
- @@map_input =
nil
Class Method Summary
collapse
Class Method Details
.job(&block) ⇒ Object
55
56
57
|
# File 'lib/ralph.rb', line 55
def self.job(&block)
self.instance_eval(&block) if block_given?end
|
.mapper(format = nil, &block) ⇒ Object
20
21
22
23
|
# File 'lib/ralph.rb', line 20
def self.mapper(format = nil, &block)
Job.send(:define_method, :map, &block)
@@map_input = format
end
|
.reducer(&block) ⇒ Object
25
26
27
|
# File 'lib/ralph.rb', line 25
def self.reducer(&block)
Job.send(:define_method, :reduce, &block)
end
|
.run_mapper!(input = STDIN, output = STDOUT) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/ralph.rb', line 29
def self.run_mapper!(input = STDIN, output = STDOUT)
j = Job.new
j.output = output
if @@map_input == :csv
CSVScan.scan(input) do |row|
j.map(row)
end
else
input.each_line do |line|
j.map(line)
end
end
end
|
.run_reducer!(input = STDIN, output = STDOUT) ⇒ Object