Module: Readmill::Client::Highlights

Included in:
Readmill::Client
Defined in:
lib/readmill/client/highlights.rb

Overview

Public: This module will bring all of the methods from the highlight section of the API.

Instance Method Summary collapse

Instance Method Details

#highlight(id, opts = {}) ⇒ Object

Public: Get a specific highlight from readmill.

id - The id of a highlight to get from readmill. opts - A Hash of options used to modify the results. All of the values

of this Hash will be forwarded to the API as parameters
(default: {}).

Returns a Hashie::Mash.



42
43
44
45
46
47
48
# File 'lib/readmill/client/highlights.rb', line 42

def highlight(id, opts={})
  if opts.delete(:comments)
    get("highlights/#{id}/comments", opts).items
  else
    get("highlights/#{id}", opts)
  end
end

#highlights(opts = {}) ⇒ Object

Public: Get all highlights from readmill.

opts - A Hash of options used to modify the results. All of the values

of this Hash will be forwarded to the API as parameters
(default: {}).
:reading_id - Limit the highlights to a specific reading.
:user_id - Limit the highlights to a specific user.

Returns an Array.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/readmill/client/highlights.rb', line 17

def highlights(opts={})
  if !opts[:user_id].nil? && !opts[:reading_id].nil?
    raise ArgumentError,
      'You can pass either reading_id or user_id, but not both.'
  end

  if !opts[:user_id].nil?
    url = "users/#{opts.delete(:user_id)}/highlights"
  elsif !opts[:reading_id].nil?
    url = "readings/#{opts.delete(:reading_id)}/highlights"
  else
    url = 'highlights'
  end

  get(url, opts).items
end