Class: Ketchup::MeetingArray
- Inherits:
-
Array
- Object
- Array
- Ketchup::MeetingArray
- 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
-
#build(params = {}) ⇒ Ketchup::Meeting
Create a new unsaved meeting object.
-
#create(params = {}) ⇒ Ketchup::Meeting
Create a new (saved) meeting object.
-
#initialize(api) ⇒ MeetingArray
constructor
Create a new array from a given api connection.
-
#previous ⇒ Array
Requests a set of meetings that have already happened from the API.
-
#today ⇒ Array
Requests a set of meetings that will happen today from the API.
-
#upcoming ⇒ Array
Requests a set of meetings that happen on days after today from the API.
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.
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.
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.
57 58 59 60 61 |
# File 'lib/ketchup/meeting_array.rb', line 57 def create(params = {}) meeting = build(params) meeting.save meeting end |
#previous ⇒ Array
Requests a set of meetings that have already happened from the API.
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 |