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