Class: TMail::FilePort
- Defined in:
- lib/action_mailer/vendor/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.
48 49 50 51 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 48 def initialize( fname ) @filename = File.(fname) super() end |
Instance Attribute Details
#filename ⇒ Object (readonly) Also known as: ident
Returns the value of attribute filename.
53 54 55 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 53 def filename @filename end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
57 58 59 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 57 def ==( other ) other.respond_to?(:filename) and @filename == other.filename end |
#aopen(&block) ⇒ Object
88 89 90 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 88 def aopen( &block ) File.open(@filename, 'a', &block) end |
#copy_to(port) ⇒ Object Also known as: cp
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 115 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
63 64 65 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 63 def hash @filename.hash end |
#inspect ⇒ Object
67 68 69 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 67 def inspect "#<#{self.class}:#{@filename}>" end |
#move_to(port) ⇒ Object Also known as: mv
104 105 106 107 108 109 110 111 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 104 def move_to( port ) begin File.link @filename, port.filename rescue Errno::EXDEV copy_to port end File.unlink @filename end |
#read_all ⇒ Object
93 94 95 96 97 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 93 def read_all ropen {|f| return f.read } end |
#remove ⇒ Object
100 101 102 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 100 def remove File.unlink @filename end |
#reproducible? ⇒ Boolean
71 72 73 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 71 def reproducible? true end |
#ropen(&block) ⇒ Object
80 81 82 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 80 def ropen( &block ) File.open(@filename, &block) end |
#size ⇒ Object
75 76 77 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 75 def size File.size @filename end |
#wopen(&block) ⇒ Object
84 85 86 |
# File 'lib/action_mailer/vendor/tmail/port.rb', line 84 def wopen( &block ) File.open(@filename, 'w', &block) end |