Sha256: 20ea4879dee433b7fbbc19d0e8b1f224df9315a4a9427353d6e4b1d9f7e6aea1

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

class Pupil
  # @param [Fixnum] id id
  # @return [Pupil::User] response
  def block param
    case param.keys[0].to_sym
    when :screen_name
      response = self.post("/blocks/create.json", {:screen_name => param.values[0]})
    when :id
      response = self.post("/blocks/create.json", {:user_id => param.values[0]})
    end
    
    if response.class == Hash && response["id"]
      return User.new response
    end
    return false
  end

  # @param [Fixnum] id id
  # @return [Pupil::User] response
  def unblock param
    case param.keys[0].to_sym
    when :screen_name
      response = self.post("/blocks/destroy.json", {:screen_name => param.values[0]})
    when :id
      response = self.post("/blocks/destroy.json", {:user_id => param.values[0]})
    end
    
    if response.class == Hash && response["id"]
      return User.new response
    end
    return false
  end

  # @return [Array] list of blocking users
  def blocking
    response = self.get("/blocks/blocking.json")
    users = Array.new
    response["users"].each do |element|
      user = User.new element
      users << user
    end
    return users
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pupil-0.1.5 lib/pupil/blocks.rb
pupil-0.1.4 lib/pupil/blocks.rb
pupil-0.1.3 lib/pupil/blocks.rb
pupil-0.1.2 lib/pupil/blocks.rb
pupil-0.1.1 lib/pupil/blocks.rb