class WWW::Wassr

Constants

WASSR
WASSR_API_URL
WASSR_RUBY

Public Class Methods

get(key, id=nil) click to toggle source
# File lib/wassruby.rb, line 53
def get(key, id=nil)
  case key
  when :public_timeline
    get_res_body_json(:PUBLIC_TIMELINE)
  when :user_timeline 
    get_res_body_json(:USER_TIMELINE, id)     if id != nil
  when :user_show #get new one message of user
    get_res_body_json(:USER_SHOW, id)         if id != nil
  when :new_channel 
    get_res_body_rss(:NEW_CHANNEL)
  when :channel_check 
    get_res_body_json(:CHANNEL_CHECK, id)     if id != nil
  when :sl_timeline
    get_res_body_json(:SL_TIMELINE)
  when :user_channel_list 
    get_res_body_json(:USER_CHANNEL_LIST, id) if id != nil
  when :todo_list 
    get_res_body_json(:TODO_LIST)
  end
end
get_body(api_add, id="") click to toggle source
# File lib/wassruby.rb, line 41
def get_body(api_add, id="")
  Net::HTTP.new(WASSR, 80).get(WASSR_API_URL[api_add] << id).body
end
get_res_body_json(api_add, id="") click to toggle source
# File lib/wassruby.rb, line 45
def get_res_body_json(api_add, id="")
  JSON.parse(get_body(api_add, id))
end
get_res_body_rss(api_add, id="") click to toggle source
# File lib/wassruby.rb, line 49
def get_res_body_rss(api_add, id="")
  RSS::Parser.parse(get_body(api_add, id))
end
new(login_id, password) click to toggle source
# File lib/wassruby.rb, line 30
def initialize(login_id, password)
  @login_id = login_id
  @password = password
  @http = Net::HTTP.new(WASSR, 80)
end
start(login_id, password, &block) click to toggle source
# File lib/wassruby.rb, line 37
def start(login_id, password, &block)
  block.call(WWW::Wassr.new(login_id, password))
end

Public Instance Methods

post(key, val="") click to toggle source
# File lib/wassruby.rb, line 82
def post(key, val="")
  case key
  when :update
    post!(:UPDATE, val)
  when :todo_update 
    post!(:TODO_UPDATE, val)
  end
end
post!(api_key, val) click to toggle source
# File lib/wassruby.rb, line 75
def post!(api_key, val)
  req = Net::HTTP::Post.new(WASSR_API_URL[api_key] << CGI.escape(val) <<
                            "&source=" << WASSR_RUBY)
  req.basic_auth(@login_id, @password)
  res = @http.request(req)
end