Guest User

Untitled

a guest
Feb 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. require 'mrtoolkit'
  3. class MainMap < MapBase
  4. def initialize(out_fd=STDOUT)
  5. @out_fd = out_fd
  6. end
  7. def declare
  8. #usual emits and field calls here
  9. end
  10. def process(input, output)
  11. #Standard line-proccesing.
  12. #Remember to return your output object!
  13. end
  14. end
  15.  
  16. action = MainMap.new
  17. action.declare
  18. action.prepare
  19. items_per_line = #define this value
  20. STDIN.each_line do |line|
  21. if line.scan(/\t/).size < items_per_line
  22. STDERR.puts "insufficient data on line #{STDIN.lineno}."
  23. else
  24. input = action.new_input(line)
  25. output = action.process(input, action.new_output)
  26. action.write_out(output)
  27. end
  28. end
Add Comment
Please, Sign In to add comment