class ElapsedWatch::EventCollection

The event collection holds all the events to watch.

Public Class Methods

new(event_file_name=nil) click to toggle source

Set up the EventCollection by passing in a file name that contains the events. If omitted or nil, the default file name at $HOME/.eventsrc will be used.

# File lib/elapsed_watch/event_collection.rb, line 22
def initialize(event_file_name=nil)
  self.event_file = event_file_name ||= DEFAULT_EVENT_FILE
end

Public Instance Methods

event_file() click to toggle source

Get the event file name

# File lib/elapsed_watch/event_collection.rb, line 27
def event_file()
  @event_file
end
event_file=(fn) click to toggle source

Assign the event file name and reload the contents of the file

# File lib/elapsed_watch/event_collection.rb, line 32
def event_file=(fn)
  @event_file=fn
  self.reload()
end
reload() click to toggle source

Reload the events from the event file. Existing events are deleted first.

# File lib/elapsed_watch/event_collection.rb, line 39
def reload()
  self.clear
  self.concat File.read(event_file).split(/\r?\n/).map{|e| Event.new(e)}
end