Module: Hyaku

Defined in:
lib/hyaku.rb

Overview

Hyakunin ishu search text

Class Method Summary collapse

Class Method Details

.viewObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/hyaku.rb', line 17

def view
  encoding_style

  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?
      f.close
    elsif !f.eof
      begin
        raise Hyaku
      rescue StandardError => ee
        puts ee.backtrace
        puts ee.backtrace_locations
        exit!
      end
    end
  end
end