Class: Bushido::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/bushido/event.rb

Overview

Bushido::Event lists all the events from the Bushido server. All events are hashes with the following keys:

  • category

  • name

  • data

Data will hold the arbitrary data for the type of event signalled

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Event

Returns a new instance of Event.



34
35
36
37
38
# File 'lib/bushido/event.rb', line 34

def initialize(options={})
  @category = options["category"]
  @name = options["name"]
  @data = options["data"]
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



15
16
17
# File 'lib/bushido/event.rb', line 15

def category
  @category
end

#dataObject (readonly)

Returns the value of attribute data.



15
16
17
# File 'lib/bushido/event.rb', line 15

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/bushido/event.rb', line 15

def name
  @name
end

Class Method Details

.allObject

Lists all events



19
20
21
# File 'lib/bushido/event.rb', line 19

def all
  @@events.collect{ |e| Event.new(e) }
end

.firstObject

Lists the first (oldest) event



24
25
26
# File 'lib/bushido/event.rb', line 24

def first
  Event.new(@@events.first)
end

.lastObject

Lists the last (newest) event



29
30
31
# File 'lib/bushido/event.rb', line 29

def last
  Event.new(@@events.last)
end