Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'mrtoolkit'
- class MainMap < MapBase
- def initialize(out_fd=STDOUT)
- @out_fd = out_fd
- end
- def declare
- #usual emits and field calls here
- end
- def process(input, output)
- #Standard line-proccesing.
- #Remember to return your output object!
- end
- end
- action = MainMap.new
- action.declare
- action.prepare
- items_per_line = #define this value
- STDIN.each_line do |line|
- if line.scan(/\t/).size < items_per_line
- STDERR.puts "insufficient data on line #{STDIN.lineno}."
- else
- input = action.new_input(line)
- output = action.process(input, action.new_output)
- action.write_out(output)
- end
- end
Add Comment
Please, Sign In to add comment