class RqrcodePngBin::FileReader

Public Class Methods

new(file) click to toggle source
# File lib/rqrcode_png_bin/file_reader.rb, line 3
def initialize(file)
  @file = open(file, 'r:utf-8')
  @pat  = %r{\A([^\t]+)(?:\t([^\t]+))?\z}

  @str  = nil
  @dest = nil
end

Public Instance Methods

each(&block) click to toggle source
param

Proc block

# File lib/rqrcode_png_bin/file_reader.rb, line 14
def each(&block)
  @file.each_line {|line|
    split!(line.chomp)
    block.call(@str, @dest) if @str and @dest
  }
end
split!(line) click to toggle source
param

String line

# File lib/rqrcode_png_bin/file_reader.rb, line 24
def split!(line)
  @pat =~ line

  @str  = $1
  @dest = $2 ? $2 : "#{$1.gsub(/\//, '%2F')}.png" if $1
end