module Hyaku

Hyakunin ishu search text

Public Instance Methods

view() click to toggle source
# File lib/hyaku.rb, line 17
def view
  one = "#{File.dirname(__FILE__)}/txt/hyakunin.txt"

  open(one) do |f|
    while (str2 = f.gets)
      str = str2.chomp!
      twice = ARGV[1]
      three_act = /#{twice}/o

      begin
        if str =~ three_act
          printf('%2d : %s', f.lineno, str)
          puts ''
        end
      rescue Timeout::Error
        exit!
      end
    end

    if f.eof?
      puts ''
    elsif !f.eof
      begin
        raise Hyaku
      rescue StandardError => ee
        puts ee.backtrace
        puts ee.backtrace_locations
        exit!
      end
    end
  end
end