Sha256: f18ade31862cabe5a5ea763139d0513633a8b5ff604efebfb8dd088360f57f59

Contents?: true

Size: 874 Bytes

Versions: 2

Compression:

Stored size: 874 Bytes

Contents

class Pupil
  # @param [Fixnum] id id
  # @return [Pupil::User] response
  def block(param)
    response = self.post("/1.1/blocks/create.json", {guess_parameter(param) => param})
    
    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)
    response = self.post("/1.1/blocks/destroy.json", {guess_parameter(param) => param})
    
    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("/1.1/blocks/list.json")
    return [] if response["nilclasses"]
    users = Array.new
    response["users"].each do |element|
      user = User.new element
      users << user
    end
    return users
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pupil-0.6.3 lib/pupil/blocks.rb
pupil-0.6.2 lib/pupil/blocks.rb