Class: RubySmart::SimpleLogger::Devices::ProcDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_smart/simple_logger/devices/proc_device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#statusObject (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

#closeObject

disables writing



26
27
28
# File 'lib/ruby_smart/simple_logger/devices/proc_device.rb', line 26

def close
  @status = false
end

#reopenObject

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

Parameters:

  • data (Object)


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