Class | RDhttp |
In: |
rdstyle.rb
|
Parent: | Object |
rdtype | [R] | rdのタイプ(x3/x5) |
httpを初期化する
# File rdstyle.rb, line 484 def initialize(host, user, password) #ホスト名/ポート番号 if host =~ /^([\S\s]+?)\:(\d+?)$/ @host = $1 @port = $2.to_i else @host = host @port = 80 end @rdtype = nil @session = nil @header = Hash.new @user = user @password = password @nc = "00000001" @auth_type = "" #認証のタイプ end
uriを修正する
# File rdstyle.rb, line 577 def correct_uri(uri) if uri !~ /^\// #/ return format("/title/%s/%s", @session, uri) else return uri end end
ネットキーボードの文字列送信
# File rdstyle.rb, line 592 def get_netkeyboard(new_str) #GET /remote/netkeyboard.htm?str=xxxxx url = format("/remote/netkeyboard.htm?str=%s", CGI.escape(new_str)) return get(url) end
ネットリモコンのコード送信
# File rdstyle.rb, line 586 def get_netremocon(code) url = format("/remote/remote.htm?key=%s", code.upcase) return get(url) end
タイムバーの時刻送信
# File rdstyle.rb, line 599 def get_timebar(new_time) url = format("/remote/ts.htm?%d", new_time.to_i) return get(url) end
フレームより[contents]という名前のページ内容を返す
# File rdstyle.rb, line 530 def getcontents(uri) main_txt = get(correct_uri(uri)) main_txt.each_line do |line| if line =~ /\<frame\ssrc\=\"(.+?)\"\s+name\=\"(.+?)\"/ frame_file = $1 frame_name = $2 if frame_name =~ /(main|contents)/ #ここでrdの機種タイプがわかる? if not @rdtype @rdtype = (frame_name == "main" ? "x3" : "x5") end #相対パスの場合、絶対パスに変換 if frame_file !~ /^\// #/ frame_file = "/title" + frame_file.gsub(/\.\./, "") #/ end #セッション番号を変更 set_session(frame_file) buf = get(frame_file) #エラーチェック error_msg = parse_error(buf) if error_msg return "ERROR " + error_msg end #正常終了 return buf end end end #見つからなかったときエラーを発生 error_msg = parse_error(main_txt) if error_msg raise "ERROR " + error_msg else raise "ERROR " + main_txt end end
フレームを取得する
# File rdstyle.rb, line 507 def getframe(url) out = Hash.new main_txt = get(url) main_txt.each_line do |line| if line =~ /\<frame\ssrc\=\"(.+?)\"\s+name\=\"(.+?)\"/ frame_file = $1 frame_name = $2 # STDERR << $1 << "\n" #相対パスの場合、絶対パスに変換 if frame_file !~ /^\// #/ # frame_file = "/" + frame_file frame_file = "/title" + frame_file.gsub(/\.\./, "") #/ end #p frame_file frame_txt = get(frame_file) out[frame_name] = frame_txt end end return out end