Class: TMail::FilePort
- Defined in:
- lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb
Overview
FilePort
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filename ⇒ Object
(also: #ident)
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #aopen(&block) ⇒ Object
- #copy_to(port) ⇒ Object (also: #cp)
- #hash ⇒ Object
-
#initialize(fname) ⇒ FilePort
constructor
A new instance of FilePort.
- #inspect ⇒ Object
- #move_to(port) ⇒ Object (also: #mv)
- #read_all ⇒ Object
- #remove ⇒ Object
- #reproducible? ⇒ Boolean
- #ropen(&block) ⇒ Object
- #size ⇒ Object
- #wopen(&block) ⇒ Object
Constructor Details
#initialize(fname) ⇒ FilePort
Returns a new instance of FilePort.
50 51 52 53 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 50 def initialize( fname ) @filename = File.(fname) super() end |
Instance Attribute Details
#filename ⇒ Object (readonly) Also known as: ident
Returns the value of attribute filename.
55 56 57 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 55 def filename @filename end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
59 60 61 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 59 def ==( other ) other.respond_to?(:filename) and @filename == other.filename end |
#aopen(&block) ⇒ Object
90 91 92 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 90 def aopen( &block ) File.open(@filename, 'a', &block) end |
#copy_to(port) ⇒ Object Also known as: cp
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 117 def copy_to( port ) if FilePort === port copy_file @filename, port.filename else File.open(@filename) {|r| port.wopen {|w| while s = r.sysread(4096) w.write << s end } } end end |
#hash ⇒ Object
65 66 67 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 65 def hash @filename.hash end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 69 def inspect "#<#{self.class}:#{@filename}>" end |
#move_to(port) ⇒ Object Also known as: mv
106 107 108 109 110 111 112 113 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 106 def move_to( port ) begin File.link @filename, port.filename rescue Errno::EXDEV copy_to port end File.unlink @filename end |
#read_all ⇒ Object
95 96 97 98 99 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 95 def read_all ropen {|f| return f.read } end |
#remove ⇒ Object
102 103 104 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 102 def remove File.unlink @filename end |
#reproducible? ⇒ Boolean
73 74 75 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 73 def reproducible? true end |
#ropen(&block) ⇒ Object
82 83 84 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 82 def ropen( &block ) File.open(@filename, &block) end |
#size ⇒ Object
77 78 79 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 77 def size File.size @filename end |
#wopen(&block) ⇒ Object
86 87 88 |
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb', line 86 def wopen( &block ) File.open(@filename, 'w', &block) end |