るりまサーチ

最速Rubyリファレンスマニュアル検索!
59件ヒット [1-59件を表示] (0.100秒)

別のキーワード

  1. _builtin at
  2. _builtin values_at
  3. time at
  4. dbm values_at
  5. csv values_at

ライブラリ

クラス

キーワード

検索結果

Net::HTTP.get(host, path, port = 80) -> String (18225.0)

指定した対象に GET リクエストを送り、そのボディを 文字列として返します。

...指定した対象に GET リクエストを送り、そのボディを
文字列として返します。

対象の指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。
@param host...
...接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定します。
@param port 接続するポートを整数で指定します。
@see Net::HTTP#get...

Pathname.getwd -> Pathname (9201.0)

カレントディレクトリを元に Pathname オブジェクトを生成します。 Pathname.new(Dir.getwd) と同じです。

...カレントディレクトリを元に Pathname オブジェクトを生成します。
Pathname.new(Dir.getwd) と同じです。

//emlist[例][ruby]{
require "pathname"

Pathname.getwd #=> #<Pathname:/home/zzak/projects/ruby>
//}

@see Dir.getwd...

Net::HTTP.get_response(host, path = nil, port = nil) -> Net::HTTPResponse (6225.0)

指定した対象に GET リクエストを送り、そのレスポンスを Net::HTTPResponse として返します。

...指定した対象に GET リクエストを送り、そのレスポンスを
Net::HTTPResponse として返します。

対象の指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。...
...@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定します。
@param port 接続するポートを整数で指定します。
@see Net::HTTP#get...

Net::HTTP.get_print(host, path, port = 80) -> () (6221.0)

指定した対象から HTTP でエンティティボディを取得し、 $stdout に出力します。

...指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定...
...ートを整数で指定します。
@see Net::HTTP.get

=== 例

//emlist[][ruby]{
require 'net/http'
require 'uri'
Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
//}

もしくは

//emlist[][ruby]{
require 'net/http'
Net::HTTP.get_print 'www.example.com', '/index.html'
//}...

Pathname.pwd -> Pathname (6101.0)

カレントディレクトリを元に Pathname オブジェクトを生成します。 Pathname.new(Dir.getwd) と同じです。

...カレントディレクトリを元に Pathname オブジェクトを生成します。
Pathname.new(Dir.getwd) と同じです。

//emlist[例][ruby]{
require "pathname"

Pathname.getwd #=> #<Pathname:/home/zzak/projects/ruby>
//}

@see Dir.getwd...

絞り込み条件を変える

Data.define(*args) -> Class (3013.0)

Data クラスに新しいサブクラスを作って、それを返します。

...Data クラスに新しいサブクラスを作って、それを返します。

サブクラスでは値オブジェクトのメンバに対するアクセスメソッドが定義されています。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # =>...
...uby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}

メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。

//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:bod...
...y)
NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Respons...

Data.define(*args) {|subclass| block } -> Class (3013.0)

Data クラスに新しいサブクラスを作って、それを返します。

...Data クラスに新しいサブクラスを作って、それを返します。

サブクラスでは値オブジェクトのメンバに対するアクセスメソッドが定義されています。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # =>...
...uby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}

メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。

//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:bod...
...y)
NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Respons...