Class: TMail::StringPort
- Defined in:
- lib/gems/tmail-1.2.3.1/lib/tmail/port.rb
Overview
StringPort
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #aopen(&block) ⇒ Object
- #copy_to(port) ⇒ Object (also: #cp)
- #hash ⇒ Object
-
#initialize(str = '') ⇒ StringPort
constructor
A new instance of StringPort.
- #inspect ⇒ Object
- #move_to(port) ⇒ Object
- #remove ⇒ Object (also: #rm)
- #reproducible? ⇒ Boolean
- #ropen(&block) ⇒ Object
- #size ⇒ Object
- #string ⇒ Object
- #to_s ⇒ Object (also: #read_all)
- #wopen(&block) ⇒ Object
Constructor Details
#initialize(str = '') ⇒ StringPort
Returns a new instance of StringPort.
301 302 303 304 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 301 def initialize( str = '' ) @buffer = str super() end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
320 321 322 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 320 def ==( other ) StringPort === other and @buffer.equal? other.string end |
#aopen(&block) ⇒ Object
348 349 350 351 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 348 def aopen( &block ) @buffer ||= '' StringOutput.new(@buffer, &block) end |
#copy_to(port) ⇒ Object Also known as: cp
359 360 361 362 363 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 359 def copy_to( port ) port.wopen {|f| f.write @buffer } end |
#hash ⇒ Object
326 327 328 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 326 def hash @buffer.object_id.hash end |
#inspect ⇒ Object
330 331 332 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 330 def inspect "#<#{self.class}:id=#{sprintf '0x%x', @buffer.object_id}>" end |
#move_to(port) ⇒ Object
367 368 369 370 371 372 373 374 375 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 367 def move_to( port ) if StringPort === port str = @buffer port.instance_eval { @buffer = str } else copy_to port end remove end |
#remove ⇒ Object Also known as: rm
353 354 355 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 353 def remove @buffer = nil end |
#reproducible? ⇒ Boolean
334 335 336 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 334 def reproducible? true end |
#ropen(&block) ⇒ Object
338 339 340 341 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 338 def ropen( &block ) @buffer or raise Errno::ENOENT, "#{inspect} is already removed" StringInput.open(@buffer, &block) end |
#size ⇒ Object
316 317 318 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 316 def size @buffer.size end |
#string ⇒ Object
306 307 308 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 306 def string @buffer end |
#to_s ⇒ Object Also known as: read_all
310 311 312 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 310 def to_s @buffer.dup end |
#wopen(&block) ⇒ Object
343 344 345 346 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/port.rb', line 343 def wopen( &block ) @buffer = '' StringOutput.new(@buffer, &block) end |