るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Net::HTTPGenericRequest#path -> String (27437.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 (18421.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 (15414.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 (12344.0)

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

...t[例1 ブロックを与えずに一度に結果取得][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://www.example.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 で少しずつ読み書き。メモリ消費が少ない。
htt...
...p.request_get(uri.path) do |response|
r
esponse.read_body do |s|
f.write(s)
end
end
end
end
//}

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

Logger#formatter -> String (12326.0)

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

...rity, 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, msg|
"t...
...ime:#{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
//}...

絞り込み条件を変える

Pathname#binread(*args) -> String | nil (12314.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| .... } -> () (12244.0)

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

...t[例1 ブロックを与えずに一度に結果取得][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://www.example.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 で少しずつ読み書き。メモリ消費が少ない。
htt...
...p.request_get(uri.path) do |response|
r
esponse.read_body do |s|
f.write(s)
end
end
end
end
//}

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

REXML::Element#text(path = nil) -> String | nil (9427.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 "
//}...

Pathname#to_s -> String (9326.0)

パス名を文字列で返します。

...パス名を文字列で返します。


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

path
= Pathname.new("/tmp/hogehoge")
File.open(path)
//}...
<< 1 2 > >>