Class: Plywood::NamedIO

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/plywood/named_io.rb

Overview

This class is used as a wrapper around an io. It adds extra methods that are useful to distinguish it from other IOs in an efficient way.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, name, stream) ⇒ NamedIO

Returns a new instance of NamedIO.



9
10
11
12
13
14
# File 'lib/plywood/named_io.rb', line 9

def initialize(io, name, stream)
  super(io)
  @name = name.to_s
  @stream = stream.to_sym
  validate_stream
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/plywood/named_io.rb', line 7

def name
  @name
end

#streamObject (readonly)

Returns the value of attribute stream.



7
8
9
# File 'lib/plywood/named_io.rb', line 7

def stream
  @stream
end

Instance Method Details

#err?Boolean

Returns:



16
17
18
# File 'lib/plywood/named_io.rb', line 16

def err?
  @stream == :err
end

#out?Boolean

Returns:



20
21
22
# File 'lib/plywood/named_io.rb', line 20

def out?
  @stream == :out
end