Class: RubySmart::SimpleLogger::Devices::MemoryDevice

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemoryDevice

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

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

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

#closeObject

disables writing



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

def close
  @status = false
end

#reopenObject

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

Parameters:

  • data (Object)


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