クラス
- BasicSocket (12)
- Module (12)
-
Net
:: HTTP (180) - OptionParser (168)
モジュール
-
Net
:: HTTPHeader (72)
キーワード
- each (12)
-
each
_ capitalized _ name (12) -
each
_ header (12) -
each
_ key (12) -
each
_ name (12) - get (24)
- get2 (24)
-
get
_ fields (12) - head (12)
- head2 (24)
- on (144)
- post2 (24)
- reject (12)
-
remote
_ address (12) -
request
_ get (24) -
request
_ head (24) -
request
_ post (24) -
ruby2
_ keywords (12)
検索結果
先頭5件
-
OptionParser
# accept(klass , pat = / . * / ) {|str| . . . } -> () (24236.0) -
OptionParser.accept と同様ですが、 登録したブロックはレシーバーに限定されます。
...ptionParser.accept と同様ですが、
登録したブロックはレシーバーに限定されます。
@param klass クラスオブジェクトを与えます。
@param pat match メソッドを持ったオブジェクト(Regexp オブジェクトなど)を与えます。
//emlist[例][ruby]......{
require "optparse"
require "time"
opts = OptionParser.new
opts.accept(Time) do |s,|
begin
Time.parse(s) if s
rescue
raise OptionParser::InvalidArgument, s
end
end
opts.on("-t", "--time [TIME]", Time) do |time|
p time.class # => Time
end
opts.parse!(ARGV)
//}... -
Module
# ruby2 _ keywords(method _ name , . . . ) -> nil (6248.0) -
For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.
... the given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword arguments, t......ent is marked with a special
flag such that if it is the final element of a normal argument splat to
another method call, and that method call does not include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed through the meth......od to
other methods.
This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.
This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby ve... -
OptionParser
# reject(klass) -> () (6135.0) -
OptionParser#accept で登録したクラスとブロックを 自身から削除します。
...ptionParser#accept で登録したクラスとブロックを
自身から削除します。
@param klass 自身から削除したいクラスを指定します。
//emlist[例][ruby]{
require "optparse"
require "time"
def parse(option_parser)
option_parser.on("-t", "--time [TIME]", Time) do |t......p time.class
end
option_parser.parse(ARGV)
end
opts = OptionParser.new
opts.accept(Time) do |s,|
begin
Time.parse(s) if s
rescue
raise OptionParser::InvalidArgument, s
end
end
parse(opts) # => Time
opts.reject(Time)
parse(opts) # => unsupported argument type: Time (ArgumentErr... -
Net
:: HTTPHeader # each _ capitalized _ name {|name| . . . . } -> () (6119.0) -
保持しているヘッダ名を正規化 ('x-my-header' -> 'X-My-Header') して、ブロックに渡します。
...er' -> 'X-My-Header')
して、ブロックに渡します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_capitalized_name { |key| puts key }
# => Accept-Encoding
# => Accept
# => User-Agent
//}... -
BasicSocket
# remote _ address -> Addrinfo (6113.0) -
getpeername(2) で得られたリモートアドレス情報を Addrinfo オブジェクトとして返します。
...getpeername(2) で得られたリモートアドレス情報を
Addrinfo オブジェクトとして返します。
返されたオブジェクトの Addrinfo#protocol は 0 を
返すことに注意してください。
require 'socket'
TCPSocket.open("www.ruby-lang.org", 80) {|s|
p s.re......mote_address #=> #<Addrinfo: 221.186.184.68:80 TCP>
}
TCPServer.open("127.0.0.1", 1728) {|serv|
c = TCPSocket.new("127.0.0.1", 1728)
s = serv.accept
p s.remote_address #=> #<Addrinfo: 127.0.0.1:36504 TCP>
}
@see BasicSocket#getpeername... -
Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse (6113.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...サーバ上の path にあるエンティティを取得し、
Net::HTTPResponse のインスタンスとして返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という......Net::HTTPResponse オブジェクトは有効な body を
持ちません。
dest は時代遅れの引数です。利用しないでください。
dest を指定した場合には
ボディを少しずつ取得して順次
「dest << ボディの断片」を実行します。
@param path 取......HTTP ヘッダをハッシュで指定します。
@param dest 利用しないでください。
1.1 互換モードの場合は、レスポンスに応じて例外が発生します。
また、返り値が [レスポンスオブジェクト, そのボディ] となります。
//emlist[例][ruby... -
Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (6113.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...サーバ上の path にあるエンティティを取得し、
Net::HTTPResponse のインスタンスとして返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という......Net::HTTPResponse オブジェクトは有効な body を
持ちません。
dest は時代遅れの引数です。利用しないでください。
dest を指定した場合には
ボディを少しずつ取得して順次
「dest << ボディの断片」を実行します。
@param path 取......HTTP ヘッダをハッシュで指定します。
@param dest 利用しないでください。
1.1 互換モードの場合は、レスポンスに応じて例外が発生します。
また、返り値が [レスポンスオブジェクト, そのボディ] となります。
//emlist[例][ruby... -
Net
:: HTTP # get2(path , header = nil) -> Net :: HTTPResponse (6113.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...サーバ上の path にあるエンティティを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という......続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
大きなサイズのボディを一度に読みだすとまずく、
小さなサイズに分けて取りだしたい場合にはこれを利用します。
@param path 取得するエンティティ......トの HTTP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# example
response = http.request_get('/index.html')
p response['content-type']
puts response.body # body is already read
# using block
http.request_get('/index.html') {|response|
p response['content-type']... -
Net
:: HTTP # get2(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (6113.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...サーバ上の path にあるエンティティを取得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という......続を維持した状態で Net::HTTPResponse
オブジェクトをブロックに渡します。
大きなサイズのボディを一度に読みだすとまずく、
小さなサイズに分けて取りだしたい場合にはこれを利用します。
@param path 取得するエンティティ......トの HTTP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# example
response = http.request_get('/index.html')
p response['content-type']
puts response.body # body is already read
# using block
http.request_get('/index.html') {|response|
p response['content-type']...