るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. rdoc/require require

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Net::HTTPGenericRequest#path -> String (21337.0)

リクエストする path を文字列で返します。

...リクエストする path を文字列で返します。

//emlist[例][ruby]{
require
'net/http'

uri = URI.parse('http://www.example.com/index.html')
r
eq = Net::HTTP::Get.new(uri.request_uri)
r
eq.path # => "/index.html"
//}...

Rake::PackageTask#package_dir_path -> String (12321.0)

パッケージに含むファイルを配置するディレクトリを返します。

...パッケージに含むファイルを配置するディレクトリを返します。

//emlist[][ruby]{
# Rakefile での記載例とする
require
'rake/packagetask'

R
ake::PackageTask.new("sample", "1.0.0") do |package_task|
package_task.package_dir_path # => "pkg/sample-1.0.0"
end
//}...

REXML::Element#xpath -> String (9314.0)

文書上の対象の要素にのみマッチする xpath 文字列を返します。

...ッチする xpath 文字列を返します。

//emlist[][ruby]{
require
'rexml/document'
doc = REXML::Document.new('<a><b/><c/></a>')
c = doc.root.elements[2] # <a> .. </a> の中の <c/> 要素
c # => <c/>
c.xpath # => "/a/c"
doc = REXML::Document.new('<a><b/><b/></a>')
b = doc.root.elements[2] #...
...<a> .. </a> の中の2番目の <b/> 要素
b # => <b/>
b.xpath # => "/a/b[2]"
//}...

Net::HTTPResponse#read_body(dest=nil) -> String|nil (9244.0)

ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。

...果取得][ruby]{
require
'net/http'

uri = "http://www.example.com/index.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
r
esponse.read_body[0..10] # => "<!doctype h"
//}

//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require
'net/http'

uri = URI.parse('http:/...
...com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
r
esponse.read_...
...body do |s|
f.write(s)
end
end
end
end
//}

一度ブロックを与えずにこのメソッドを呼んだ場合には、
次からはすでに読みだしたボディを文字列として
返します。また一度ブロックを与えてこのメソッドを呼んだ場合に...

Pathname#binread(*args) -> String | nil (9214.0)

IO.binread(self.to_s, *args)と同じです。

...IO.binread(self.to_s, *args)と同じです。

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

path
name = Pathname("testfile")
path
name.binread # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
path
name.binread(20) # => "This is line one\nThi"
path
name.binread(2...
...0, 10) # => "ne one\nThis is line "
//}

@see IO.binread...

絞り込み条件を変える

Net::HTTPResponse#read_body {|str| .... } -> () (9144.0)

ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。

...果取得][ruby]{
require
'net/http'

uri = "http://www.example.com/index.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
r
esponse.read_body[0..10] # => "<!doctype h"
//}

//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require
'net/http'

uri = URI.parse('http:/...
...com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
r
esponse.read_...
...body do |s|
f.write(s)
end
end
end
end
//}

一度ブロックを与えずにこのメソッドを呼んだ場合には、
次からはすでに読みだしたボディを文字列として
返します。また一度ブロックを与えてこのメソッドを呼んだ場合に...

Logger#formatter -> String (6220.0)

ログを出力する際に使用するフォーマッターを取得します。

...数 (severity, time, program name, message) を受けとります。

//emlist[例][ruby]{
require
'logger'

logger = Logger.new(STDOUT)
logger.formatter # => nil
logger.info("test")
# => I, [2019-05-09T22:13:56.509159 #13912] INFO -- : test

ltsv_formatter = proc { |severity, timestamp, progname,...
...g|
"time:#{timestamp}\tlevel:#{severity}\tprogname:#{progname}\tmessage:#{msg}\n"
}
logger.formatter = ltsv_formatter
logger.formatter # => #<Proc:0x00007fa3048b8e00@/path/to/file:8>
logger.info("MyApp") { "test" }

# => time:2019-05-09 22:13:56 +0900 level:INFO progname:MyApp message:test
//}...

OptionParser#program_name -> String (6220.0)

プログラムの名前を文字列で返します。

...字列で返します。

デフォルトは $0 が使われます。

@return プログラムの名前を文字列で返します。

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

OptionParser.new do |opts|
p $0 # => /path/to/filename.rb
p opts.program_name # => filename
end
//}...

REXML::Element#text(path = nil) -> String | nil (3327.0)

先頭のテキスト子ノードの文字列を返します。

...セスできないことに注意してください。

r
aw モードの設定は無視され、常に正規化されたテキストを返します。
R
EXML::Text#value も参照してください。

path
を渡した場合は、その XPath 文字列で指定される
テキストノードの文...
...を返します。

@param path XPath文字列
@see REXML::Element#get_text

//emlist[][ruby]{
require
'rexml/document'
doc = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
# doc.root (<p> ... </p>) は2つのテキストノード("some text " と " more text"
# を持って...
...いるが、前者を返す
doc.root.text # => "some text "
//}...
<< 1 2 > >>