Class: Britebox::EventLog

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/britebox/event_log.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventLog

Returns a new instance of EventLog.



9
10
11
# File 'lib/britebox/event_log.rb', line 9

def initialize
  @log_lines = []
end

Instance Attribute Details

#log_linesObject

Returns the value of attribute log_lines.



7
8
9
# File 'lib/britebox/event_log.rb', line 7

def log_lines
  @log_lines
end

Class Method Details

.empty?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/britebox/event_log.rb', line 13

def self.empty?
  self.instance.log_lines.empty?
end

.popObject



27
28
29
# File 'lib/britebox/event_log.rb', line 27

def self.pop
  self.instance.log_lines.pop
end

.push(event_type, message) ⇒ Object Also known as: add



17
18
19
20
21
22
23
24
25
# File 'lib/britebox/event_log.rb', line 17

def self.push(event_type, message)
  event = OpenStruct.new(type: event_type, message: message, time: Time.now)
  self.instance.log_lines.push(event)

  # if Britebox::Config.log ...
  # save event to log

  true
end