Sha256: e03ee20d32cb2a8bd52fa545c2cd16a255220fd25f29fe120338b3694e9b4ad7

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

class Pupil
  # @param [Fixnum] id id
  # @return [Hash] 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 [Hash] 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 [Hash] list of blocking users
  def blocking
    response = self.get("/blocks/blocking.json")
    p response
    users = Array.new
    response["users"].each do |element|
      user = User.new element
      users << user
    end
    return users
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pupil-0.1.0 lib/pupil/blocks.rb