Class: TMail::StringPort
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.
275 276 277 278 |
# File 'lib/tmail-pure/port.rb', line 275 def initialize(str = '') @buffer = str super() end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
294 295 296 |
# File 'lib/tmail-pure/port.rb', line 294 def ==(other) other.is_a?(StringPort) and @buffer.equal?(other.string) end |
#aopen(&block) ⇒ Object
323 324 325 326 |
# File 'lib/tmail-pure/port.rb', line 323 def aopen(&block) @buffer ||= '' StringOutput.new(@buffer, &block) end |
#copy_to(port) ⇒ Object Also known as: cp
334 335 336 337 338 |
# File 'lib/tmail-pure/port.rb', line 334 def copy_to(port) port.wopen {|f| f.write @buffer } end |
#hash ⇒ Object
300 301 302 |
# File 'lib/tmail-pure/port.rb', line 300 def hash @buffer.object_id.hash end |
#inspect ⇒ Object
304 305 306 |
# File 'lib/tmail-pure/port.rb', line 304 def inspect "#<#{self.class}:id=#{sprintf '0x%x', @buffer.object_id}>" end |
#move_to(port) ⇒ Object
342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/tmail-pure/port.rb', line 342 def move_to(port) if port.is_a?(StringPort) tmp = @buffer port.instance_eval { @buffer = tmp } else copy_to port end remove end |
#remove ⇒ Object Also known as: rm
328 329 330 |
# File 'lib/tmail-pure/port.rb', line 328 def remove @buffer = nil end |
#reproducible? ⇒ Boolean
308 309 310 |
# File 'lib/tmail-pure/port.rb', line 308 def reproducible? true end |
#ropen(&block) ⇒ Object
312 313 314 315 316 |
# File 'lib/tmail-pure/port.rb', line 312 def ropen(&block) # FIXME: Should we raise ENOENT? raise Errno::ENOENT, "#{inspect} is already removed" unless @buffer StringInput.open(@buffer, &block) end |
#size ⇒ Object
290 291 292 |
# File 'lib/tmail-pure/port.rb', line 290 def size @buffer.size end |
#string ⇒ Object
280 281 282 |
# File 'lib/tmail-pure/port.rb', line 280 def string @buffer end |
#to_s ⇒ Object Also known as: read_all
284 285 286 |
# File 'lib/tmail-pure/port.rb', line 284 def to_s @buffer.dup end |
#wopen(&block) ⇒ Object
318 319 320 321 |
# File 'lib/tmail-pure/port.rb', line 318 def wopen(&block) @buffer = '' StringOutput.new(@buffer, &block) end |