るりまサーチ

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

別のキーワード

  1. _builtin <
  2. bigdecimal <
  3. float <
  4. complex <
  5. module <

ライブラリ

キーワード

検索結果

<< 1 2 > >>

RubyVM::InstructionSequence#path -> String (18126.0)

self が表す命令シーケンスの相対パスを返します。

...を文字列から作成していた
場合は "<compiled>" を返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
# => "<compiled>"

例2: RubyVM::InstructionSequence.co...
...mpile_file を使用した場合

# /tmp/method.rb
def hello
puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('method.rb')
> iseq.path # => "method.rb"

@see RubyVM::InstructionSequence#absolute_path...

Pathname#<=>(other) -> -1 | 0 | 1 | nil (9101.0)

パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合 は正、other が大きい場合は負を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。

...other は Pathname オブジェクトでなければなりません。

パス名の比較は単純にパス文字列の比較によって行われるので、論理的に
同じパスでもパス文字列が違えば異なると判断されます。

@param other 比較対象の Pathname オブジ...
...ェクトを指定します。

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

p Pathname.new("foo/bar") <=> Pathname.new("foo/bar")
p Pathname.new("foo/bar") <=> Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") <=> Pathname.new("foo/bar")
# => 0
# 1
# -1
//}...

File::Stat#<=>(o) -> Integer | nil (6137.0)

ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。

...fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"

p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}...

REXML::Element#xpath -> String (6137.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]"
//}...

RubyVM::InstructionSequence#absolute_path -> String | nil (6126.0)

self が表す命令シーケンスの絶対パスを返します。

...します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.absolute_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello...
...puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@see RubyVM::InstructionSequence#path...

絞り込み条件を変える

REXML::Elements#each(xpath = nil) {|element| ... } -> [REXML::Elements] (143.0)

全ての子要素に対しブロックを呼び出します。

...xpath を指定した場合には、その XPath 文字列に
マッチする要素に対しブロックを呼び出します。

REXML::XPath.each などとは異なり、要素以外の
テキストノードなどはすべて無視されることに注意してください。

@param xpath XPath...
.../xpath'
doc = REXML::Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
# <b/>,<c/>,<d/>,<b/>,<c/>, <d/> がブロックに渡される
doc.root.elements.each {|e|p e}
# <b/>, <b/> がブロックに渡される
doc.root.elements.each('b') {|e|p e} #-> Yields b, b elements
# <b/>,<c/>,<d/>,<b/>,<c/...
...>,<d/> がブロックに渡される
doc.root.elements.each('child::node()') {|e|p e}
# <b/>,<c/>,<d/>,"sean",<b/>,<c/>,<d/> がブロックに渡される
REXML::XPath.each(doc.root, 'child::node()'){|node| p node }
//}...

REXML::Elements#to_a(xpath = nil) -> [REXML::Element] (137.0)

すべての子要素の配列を返します。

...列を返します。

xpath を指定した場合は、その XPath 文字列に
マッチする要素の配列を返します。

REXML::Elements#each と同様、REXML::XPath.match などと
異なり、要素以外の子ノードは無視されます。

@param xpath XPath文字列

//emlist[][r...
...uby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.elements.to_a # => [<b/>, <c/>]
doc.root.elements.to_a("child::node()") # => [<b/>, <c/>]
REXML::XPath.match(doc.root, "child::node()") # => ["sean", <b/>, "elliott", <c/>]
//}...

REXML::Element#get_text(path = nil) -> REXML::Text | nil (120.0)

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

...XML::Text#value も参照してください。

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

テキストノードがない場合には nil を返します。

@param path XPath文字列
@see REXML::Element#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.get_text.value # => "some text "
//}...

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

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

...XML::Text#value も参照してください。

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

テキストノードがない場合には nil を返します。

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

//eml...
...ist[][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 "
//}...

REXML::Elements#delete_all(xpath) -> [REXML::Element] (119.0)

xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。

...xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。

@param xpath 取り除く要素を指し示す XPath 文字列

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><c/><c/><c/><c/></a>')
doc.elements.delete_all("a/c") # => [<c/>, <...
...c/>, <c/>, <c/>]
doc.to_s # => "<a/>"
//}...

絞り込み条件を変える

<< 1 2 > >>