Class: RubySmart::SimpleLogger::Devices::ProcDevice
- Inherits:
-
Object
- Object
- RubySmart::SimpleLogger::Devices::ProcDevice
- Defined in:
- lib/ruby_smart/simple_logger/devices/proc_device.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#close ⇒ Object
disables writing.
-
#initialize(proc) ⇒ ProcDevice
constructor
A new instance of ProcDevice.
-
#reopen ⇒ Object
enables writing.
-
#write(data) ⇒ Object
(also: #<<)
pass data to the callback.
Constructor Details
#initialize(proc) ⇒ ProcDevice
Returns a new instance of ProcDevice.
10 11 12 13 |
# File 'lib/ruby_smart/simple_logger/devices/proc_device.rb', line 10 def initialize(proc) @proc = proc @status = true end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/ruby_smart/simple_logger/devices/proc_device.rb', line 8 def status @status end |
Instance Method Details
#close ⇒ Object
disables writing
26 27 28 |
# File 'lib/ruby_smart/simple_logger/devices/proc_device.rb', line 26 def close @status = false end |
#reopen ⇒ Object
enables writing
31 32 33 |
# File 'lib/ruby_smart/simple_logger/devices/proc_device.rb', line 31 def reopen @status = true end |
#write(data) ⇒ Object Also known as: <<
pass data to the callback
17 18 19 20 21 |
# File 'lib/ruby_smart/simple_logger/devices/proc_device.rb', line 17 def write(data) return false unless status @proc.call(data) end |