Class: Net::WriteAdapter
- Inherits:
-
Object
- Object
- Net::WriteAdapter
- Defined in:
- lib/net/protocol.rb
Overview
The writer adapter class
Instance Method Summary collapse
- #<<(str) ⇒ Object
-
#initialize(writer) ⇒ WriteAdapter
constructor
A new instance of WriteAdapter.
- #inspect ⇒ Object
- #printf(*args) ⇒ Object
- #puts(str = '') ⇒ Object
- #write(str) ⇒ Object (also: #print)
Constructor Details
#initialize(writer) ⇒ WriteAdapter
Returns a new instance of WriteAdapter.
487 488 489 |
# File 'lib/net/protocol.rb', line 487 def initialize(writer) @writer = writer end |
Instance Method Details
#<<(str) ⇒ Object
501 502 503 504 |
# File 'lib/net/protocol.rb', line 501 def <<(str) write str self end |
#inspect ⇒ Object
491 492 493 |
# File 'lib/net/protocol.rb', line 491 def inspect "#<#{self.class} writer=#{@writer.inspect}>" end |
#printf(*args) ⇒ Object
510 511 512 |
# File 'lib/net/protocol.rb', line 510 def printf(*args) write sprintf(*args) end |
#puts(str = '') ⇒ Object
506 507 508 |
# File 'lib/net/protocol.rb', line 506 def puts(str = '') write str.chomp("\n") + "\n" end |
#write(str) ⇒ Object Also known as: print
495 496 497 |
# File 'lib/net/protocol.rb', line 495 def write(str) @writer.call(str) end |