class Intar::RedirectFile

Public Class Methods

detect(line, outfile) click to toggle source
# File lib/intar/redirect.rb, line 48
def detect line, outfile
  if line.slice! /\s+>(>)?(\S+|"((?:[^\\"]|\\.)*)")\z/ then
    p = $3 ? ($3.gsub /\\(.)/, "\\1") : $2
    append = true if $1
    new p, append
  elsif outfile then
    new outfile.to_s, true
  end
end
new(path, append) click to toggle source
# File lib/intar/redirect.rb, line 58
def initialize path, append
  @path, @append = path, append
end

Public Instance Methods

outfile() click to toggle source
# File lib/intar/redirect.rb, line 61
def outfile
  File.open @path, (@append ? "a" : "w") rescue raise Failed, "File error: #$!"
end