Class: Ketchup::MeetingArray

Inherits:
Array
  • Object
show all
Defined in:
lib/ketchup/meeting_array.rb

Overview

A collection of meeting for the current profile, which allows for the creation of new meetings. It’s really just a slightly special subclass of Array.

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ MeetingArray

Create a new array from a given api connection. This will make the request to the API to retrieve all meetings for the profile.

This isn’t something you need to call yourself - just call the meetings method on your profile object instead.

Examples:

meetings = Ketchup::MeetingArray.new api

Parameters:

See Also:



17
18
19
20
21
22
23
# File 'lib/ketchup/meeting_array.rb', line 17

def initialize(api)
  @api = api
  
  replace @api.get('/meetings.json').collect { |hash|
    Ketchup::Meeting.new(@api, hash)
  }
end

Instance Method Details

#build(params = {}) ⇒ Ketchup::Meeting

Create a new unsaved meeting object. The only parameters you really need to worry about are the title and date - the rest are optional, but mentioned in the notes for the Meeting class.

Don’t forget: the parameter keys need to be strings, not symbols.

Examples:

profile.meetings.build 'title' => 'Job Interview', 'date' => 'Tomorrow'

Parameters:

  • params (Hash) (defaults to: {})

    The meeting’s details

Returns:

See Also:



38
39
40
41
42
# File 'lib/ketchup/meeting_array.rb', line 38

def build(params = {})
  meeting = Ketchup::Meeting.new @api, params
  push meeting
  meeting
end

#create(params = {}) ⇒ Ketchup::Meeting

Create a new (saved) meeting object. The only parameters you really need to worry about are the title and date - the rest are optional, but mentioned in the notes for the Meeting class.

Don’t forget: the parameter keys need to be strings, not symbols.

Examples:

profile.meetings.create 'title' => 'Job Interview', 'date' => 'Tomorrow'

Parameters:

  • params (Hash) (defaults to: {})

    The meeting’s details

Returns:

See Also:



57
58
59
60
61
# File 'lib/ketchup/meeting_array.rb', line 57

def create(params = {})
  meeting = build(params)
  meeting.save
  meeting
end

#previousArray

Requests a set of meetings that have already happened from the API.

Returns:

  • (Array)

    An array of previous meetings



77
78
79
80
81
# File 'lib/ketchup/meeting_array.rb', line 77

def previous
  @previous ||= @api.get('/meetings/previous.json').collect { |hash|
    Ketchup::Meeting.new(@api, hash)
  }
end

#todayArray

Requests a set of meetings that will happen today from the API.

Returns:

  • (Array)

    An array of today’s meetings



87
88
89
90
91
# File 'lib/ketchup/meeting_array.rb', line 87

def today
  @today ||= @api.get('/meetings/todays.json').collect { |hash|
    Ketchup::Meeting.new(@api, hash)
  }
end

#upcomingArray

Requests a set of meetings that happen on days after today from the API.

Returns:

  • (Array)

    An array of upcoming meetings



67
68
69
70
71
# File 'lib/ketchup/meeting_array.rb', line 67

def upcoming
  @upcoming ||= @api.get('/meetings/upcoming.json').collect { |hash|
    Ketchup::Meeting.new(@api, hash)
  }
end