Class: Bluecap::Event
- Inherits:
-
Object
- Object
- Bluecap::Event
- Defined in:
- lib/bluecap/handlers/event.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#date ⇒ Object
Converts the object’s timestamp to a %Y%m%d String.
-
#handle ⇒ Object
Store the user’s event in a bitset of all the events matching that name for the date.
-
#initialize(data) ⇒ Event
constructor
Initialize an Event handler.
-
#key ⇒ Object
Proxy for an event key.
Constructor Details
#initialize(data) ⇒ Event
Initialize an Event handler.
data - A Hash containing event data:
:id - The Integer identifer of the user that generated
the event.
:name - The String type of event.
:timestamp - The Integer UNIX timestamp when the event was created,
defaults to current time (optional).
Examples
Bluecap::Event.new(
id: 3,
name: 'Created Account',
timestamp: 1341845456
)
24 25 26 27 28 |
# File 'lib/bluecap/handlers/event.rb', line 24 def initialize(data) @id = data.fetch(:id) @name = data.fetch(:name) @timestamp = data.fetch(:timestamp, Time.now.to_i) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/bluecap/handlers/event.rb', line 6 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/bluecap/handlers/event.rb', line 6 def name @name end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/bluecap/handlers/event.rb', line 6 def @timestamp end |
Instance Method Details
#date ⇒ Object
Converts the object’s timestamp to a %Y%m%d String.
Returns the String date.
33 34 35 |
# File 'lib/bluecap/handlers/event.rb', line 33 def date Time.at(@timestamp).strftime('%Y%m%d') end |