Class: Trackerific::Event

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

Overview

Provides details for a tracking event

Instance Method Summary (collapse)

Constructor Details

- (Event) initialize(date, description, location)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Provides a new instance of Event

Parameters:

  • date (Time)

    the date / time of the event

  • description (String)

    the event’s description

  • location (String)

    where the event took place



9
10
11
12
13
# File 'lib/trackerific/event.rb', line 9

def initialize(date, description, location)
  @date = date
  @description = description
  @location = location
end

Instance Method Details

- (DateTime) date

The date and time of the event

Examples:

Get the date of an event

date = details.events.first.date

Returns:

  • (DateTime)


20
21
22
# File 'lib/trackerific/event.rb', line 20

def date
  @date
end

- (String) description

The event’s description

Examples:

Get the description of an event

description = details.events.first.description

Returns:

  • (String)


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

def description
  @description
end

- (String) location

Where the event took place (usually in City State Zip format)

Examples:

Get the location of an event

location = details.events.first.location

Returns:

  • (String)


38
39
40
# File 'lib/trackerific/event.rb', line 38

def location
  @location
end

- (String) to_s

Converts the event into a string

Examples:

Get a human-readable string from an event

event = details.event.to_s

A bulleted list of events in haml

%ul
  - details.events.each do |event|
  %li= event

Returns:

  • (String)

    converts the event into a string



51
52
53
54
55
56
# File 'lib/trackerific/event.rb', line 51

def to_s
  dte = self.date.strftime('%b %d %I:%M %P')
  des = self.description
  loc = self.location
  "#{dte} #{des} #{loc}"
end