Class: RqrcodePngBin::FileReader
- Inherits:
-
Object
- Object
- RqrcodePngBin::FileReader
- Defined in:
- lib/rqrcode_png_bin/file_reader.rb
Instance Method Summary collapse
-
#each(&block) ⇒ Object
- param
-
Proc block.
-
#initialize(file) ⇒ FileReader
constructor
A new instance of FileReader.
-
#split!(line) ⇒ Object
- param
-
String line.
Constructor Details
#initialize(file) ⇒ FileReader
Returns a new instance of FileReader.
5 6 7 8 9 10 11 |
# File 'lib/rqrcode_png_bin/file_reader.rb', line 5 def initialize(file) @file = open(file) @pat = %r{\A([^\t]+)(?:\t([^\t]+))?\z} @str = nil @dest = nil end |
Instance Method Details
#each(&block) ⇒ Object
- param
-
Proc block
16 17 18 19 20 21 |
# File 'lib/rqrcode_png_bin/file_reader.rb', line 16 def each(&block) @file.each_line {|line| split!(line.chomp) block.call(@str, @dest) } end |
#split!(line) ⇒ Object
- param
-
String line
26 27 28 29 30 31 |
# File 'lib/rqrcode_png_bin/file_reader.rb', line 26 def split!(line) @pat =~ line @str = $1 @dest = $2 ? $2 : "#{CGI.escape($1)}.png" end |