Class: Pupil::List

Inherits:
Scheme show all
Defined in:
lib/pupil/schemes.rb

Instance Method Summary collapse

Methods inherited from Scheme

#initialize, #params

Methods included from Essentials

#get, #guess_parameter, #post, #serialize_parameter

Constructor Details

This class inherits a constructor from Pupil::Scheme

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pupil::Scheme

Instance Method Details

#add(param) ⇒ Object



120
121
122
123
# File 'lib/pupil/schemes.rb', line 120

def add(param)
  response = self.post("lists/members/create.json", {:list_id => @element["id_str"], guess_parameter(param) => param})
  return List.new(response)
end

#destroyObject Also known as: delete



132
133
134
135
# File 'lib/pupil/schemes.rb', line 132

def destroy()
  response = self.post("lists/destroy.json", {:list_id => @element["id_str"]})
  return List.new(response)
end

#members(param = {}) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/pupil/schemes.rb', line 106

def members(param={})
  response = self.get("lists/members.json", {:list_id => @element["id_str"]}.update(param))
  return false unless response
  users = []
  response["users"].each do |u|
    user = User.new(u.update("_list_id" => @element["id_str"]), @access_token)
    def user.destroy()
      response = self.post("lists/members/destroy.json", {:list_id => @element["_list_id"], :user_id => @element["id_str"]})
    end
    users << user
  end
  return users
end

#statuses(param = {}) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/pupil/schemes.rb', line 86

def statuses(param={})
  response = self.get("lists/statuses.json", {:list_id => @element["id_str"]}.update(param))
  return false unless response
  statuses = []
  response.each do |status|
    statuses << Pupil::Status.new(status, @access_token)
  end
  return statuses
end

#strike(param, opts = {}) ⇒ Object Also known as: off



125
126
127
128
# File 'lib/pupil/schemes.rb', line 125

def strike(param, opts={})
  response = self.post("lists/members/destroy.json", {guess_parameter(param) => param, :list_id => @element["id_str"]}.update(opts))
  return response
end

#subscribers(param = {}) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/pupil/schemes.rb', line 96

def subscribers(param={})
  response = self.get("lists/subscribers.json", {:list_id => @element["id_str"]}.update(param))
  return false unless response
  users = []
  response["users"].each do |user|
    users << Pupil::User.new(user, @access_token)
  end
  return users
end

#userObject



84
# File 'lib/pupil/schemes.rb', line 84

def user() Pupil::User.new(@element["user"], @access_token) rescue nil; end