Class: Ketchup::Meeting

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

Overview

A Meeting - the cornerstone of Ketchup. This object tracks the meeting’s key details: the title, whether it’s public or not, the date, attendees, a description, location, project name, and the agenda items.

While you won’t want to create a new meeting from this class itself - it’s far easier to do so using a profile’s meetings array - this is a good reference point for changing and deleting meetings.

Constant Summary collapse

WriteableAttributes =
[:title, :quick, :public, :date, :attendees,
:description, :project_name, :location]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, params = {}) ⇒ Meeting

Create a new meeting, using an active API object. Keep in mind that all parameter keys must be provided as strings. The key attributes are the title and the date (the rest are optional).

The date can be defined using natural language, and the server will figure out what you mean (just like when you create a meeting on the website).

Examples:

Ketchup::Meeting.new api,
  'title'        => 'White Album Cover Brainstorming',
  'date'         => 'Tomorrow at 4pm',
  'attendees'    => 'John, Paul, George and Ringo',
  'location'     => 'Abbey Road',
  'project_name' => 'New Releases'

Parameters:

  • api (Ketchup::API)

    A connected API instance

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

    The attributes for the meeting.



38
39
40
41
42
43
44
# File 'lib/ketchup/meeting.rb', line 38

def initialize(api, params = {})
  @api = api
  
  overwrite params
  
  @items = Ketchup::ItemArray.new @api, self, (params['items'] || [])
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def api
  @api
end

#created_atObject (readonly)

Returns the value of attribute created_at.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def created_at
  @created_at
end

#itemsObject (readonly)

Returns the value of attribute items.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def items
  @items
end

#project_idObject (readonly)

Returns the value of attribute project_id.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def project_id
  @project_id
end

#public_urlObject (readonly)

Returns the value of attribute public_url.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def public_url
  @public_url
end

#shortcode_urlObject (readonly)

Returns the value of attribute shortcode_url.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def shortcode_url
  @shortcode_url
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def updated_at
  @updated_at
end

#user_idObject (readonly)

Returns the value of attribute user_id.



13
14
15
# File 'lib/ketchup/meeting.rb', line 13

def user_id
  @user_id
end

Instance Method Details

#destroyObject

Deletes the meeting from the server. If the meeting has never been saved, this method will do nothing at all.



61
62
63
64
65
# File 'lib/ketchup/meeting.rb', line 61

def destroy
  return if new_record?
  
  @api.delete "/meetings/#{shortcode_url}.json"
end

#new_record?Boolean

Indicates whether the meeting exists on the server yet.

Returns:

  • (Boolean)

    True if the meeting does not exist on the server.



71
72
73
# File 'lib/ketchup/meeting.rb', line 71

def new_record?
  shortcode_url.nil?
end

#saveObject

Saves the meeting to the server, whether it’s a new meeting or an existing one. This does not save underlying items or notes.



49
50
51
52
53
54
55
56
# File 'lib/ketchup/meeting.rb', line 49

def save
  if new_record?
    overwrite @api.post("/meetings.json", writeable_attributes)
  else
    overwrite @api.put("/meetings/#{shortcode_url}.json",
      writeable_attributes)
  end
end