lib/pupil.rb in pupil-0.0.4 vs lib/pupil.rb in pupil-0.0.5
- old
+ new
@@ -10,11 +10,10 @@
$LOAD_PATH << File.dirname(File.expand_path(__FILE__)) if RUBY_VERSION >= '1.9.0'
require 'pupil/keygen'
class Pupil
attr_reader :screen_name
-
class UnsupportedParameter < StandardError; end
# @param [Hash] pupil_key
def initialize(pupil_key)
@screen_name = pupil_key[:screen_name]
@@ -31,11 +30,11 @@
pupil_key[:access_token_secret]
)
end
# @param [Hash] parameter
- # @return [String] serialized parameters
+ # @return [String] URL Serialized parameters
def param_serializer parameter
ant = Hash.new
parameter.each do |key, value|
case key.to_sym
when :include
@@ -79,21 +78,22 @@
end
end
public
- # @return [Hash] user profile
+ # @return [Hash] User credentials
def verify_credentials
response = @access_token.get('/account/verify_credentials.xml')
doc = REXML::Document.new(response.body)
return false if doc.is_error?
user = User.new(doc.elements['/user'])
return user
end
+ # Alias to Pupil#home_timeline
# @param [Hash] param
- # @return [Hash] alias to Pupil#home_timeline
+ # @return [Array] Timeline
# @deprecated Use {#home_timeline} instead of this method because
# is was obsoleted.
def friends_timeline(param = {})
param_s = param_serializer(param)
begin
@@ -112,11 +112,11 @@
return statuses
end
# @param [Hash] param
- # @return [Array] timeline
+ # @return [Array] Timeline
def home_timeline(param = {})
param_s = param_serializer(param)
begin
response = @access_token.get("http://api.twitter.com/1/statuses/home_timeline.xml"+param_s)
rescue
@@ -130,25 +130,26 @@
statuses << status
}
return statuses
end
+ # Returning user timeline
# @param [Hash] param
# @return [Hash] timeline
# @option param [Fixnum] :user_id The ID of user
# @option param [String] :screen_name The Screen name of user
# @option param [Fixnum] :since_id
# @option param [Fixnum] :max_id
# @option param [Fixnum] :count
# @option param [Fixnum] :page Specifies
# @option param [Symbol] :trim_user
- # @option param [Symbol] :include => :rts
- # @option param [Symbol] :exclude => :replies
+ # @option param [Symbol] :include #=> [:rts]
+ # @option param [Symbol] :exclude #=> [:replies]
# @option param [Symbol] :contributor_details
# @example
# twitter = Pupil.new PUPIL_KEY
- # twitter.user_timeline(:screen_name => 'o_ame', :exclude_replies => :true).each do |status|
+ # twitter.user_timeline(:screen_name => 'o_ame', :exclude => :replies).each do |status|
# puts "#{status.user.screen_name}: #{status.text}"
# end
def user_timeline(param = {})
param_s = param_serializer(param)
begin
@@ -185,10 +186,11 @@
}
return statuses
end
+ # Returning direct messages
# @param [Hash] param
# @return [Hash] directmessages
def dm(param = {})
param_s = param_serializer(param)
begin
@@ -206,10 +208,11 @@
}
return directmessages
end
+ # Returning direct messages you sent
# @param [Hash] param
# @return [Hash] directmessage you sent
def dm_sent(param = {})
param_s = param_serializer(param)
begin
@@ -227,10 +230,11 @@
}
return directmessages
end
+ # Delete direct message
# @param [Fixnum] dm_id message id that you want to delete
# @return [Hash] response
def dm_destroy(dm_id)
begin
response = @access_token.post("http://api.twitter.com/1/direct_messages/destroy/#{dm_id}.xml")
@@ -238,10 +242,11 @@
return false
end
return response
end
+ # Check friendships
# @param [String] src source user
# @param [String] dst destination user
# @return [Boolean] return true if paired users have friendship, or ruturn false
def friendship_exists?(src, dst)
begin
@@ -256,10 +261,11 @@
else
return false
end
end
+ # Follow user for screen_name
# @param [String] name screen_name
# @return [Hash] response
def follow name
begin
response = @access_token.post("http://api.twitter.com/1/friendships/create/#{name}.xml")
@@ -267,9 +273,10 @@
return false
end
return response
end
+ # Unfollow user for screen_name
# @param [String] name screen_name
# @return [Hash] response
def unfollow name
begin
response = @access_token.post("http://api.twitter.com/1/friendships/destroy/#{name}.xml")
\ No newline at end of file