Class: Intar::RedirectFile
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, append) ⇒ RedirectFile
constructor
A new instance of RedirectFile.
- #outfile ⇒ Object
Methods inherited from Redirect
Constructor Details
#initialize(path, append) ⇒ RedirectFile
62 63 64 |
# File 'lib/intar/redirect.rb', line 62 def initialize path, append @path, @append = path, append end |
Class Method Details
.detect(line, outfile) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/intar/redirect.rb', line 52 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 |
Instance Method Details
#outfile ⇒ Object
65 66 67 |
# File 'lib/intar/redirect.rb', line 65 def outfile File.open @path, (@append ? "a" : "w") rescue raise Failed, "File error: #$!" end |