るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. range end

検索結果

<< 1 2 3 > >>

Method#>>(callable) -> Proc (18142.0)

self と引数を合成した Proc を返します。

...list[例][ruby]{
def f(x)
x * x
end


def g(x)
x + x
end


# (3 * 3) + (3 * 3)
p (method(:f) >> method(:g)).call(3) # => 18
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end

end


File.write('testfile', <<~TEXT)...
...Hello, World!
Hello, Ruby!
TEXT

pipeline = File.method(:read) >> WordScanner >> method(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

@see Proc#<<, Proc#>>...

Proc#>>(callable) -> Proc (18130.0)

self と引数を合成した Proc を返します。

...(f >> g).call(3) # => 18
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end

end


File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

pipeline = proc { |fname| File.read(fname) } >> WordScanner >>...
...method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

@see Method#<<, Method#>>...

Module#prepend(*modules) -> self (6196.0)

指定したモジュールを self の継承チェインの先頭に「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。

...を処理するため、prependの引数として
渡したモジュールのインスタンスメソッドでsuperを呼ぶことで
self のモジュール/クラスのメソッドを呼び出すことができます。

実際の処理は modules の各要素の prepend_features を後ろから...
...けです。
Module#prepend_features が継承チェインの改変を実行し、結果として上のような
処理が実現されます。そのため、prepend_features を override することで
prepend の処理を追加/変更できます。


@param modules prepend する Module を指...
...pend の組み合わせの例
module X
def foo
puts "X1" # (1x)
super # (2x)
puts "X2" # (3x)
end

end


class A
prepend X

def foo
puts "A" #(1a)
end

end


A.new.foo
# (1x) (2x)(ここの super で A#foo を呼びだす) (1a) (3x) の順に実行される
# >> X1
# >> A
# >>...

IRB::ExtendCommand::Help#execute(*names) -> nil (3006.0)

RI から Ruby のドキュメントを参照します。

...
す。

irb(main):001:0> help

Enter the method name you want to look up.
You can use tab to autocomplete.
Enter a blank line to exit.

>>
String#match
String#match

(from ruby core)
------------------------------------------------------------------------------
str.match(patt...

rexml/parsers/sax2parser (432.0)

SAX2 と同等の API を持つストリーム式の XML パーサ。

...me, *args]
end

def respond_to_missing?(name, include_private)
name != :call
end

end


parser = REXML::Parsers::SAX2Parser.new(xml)
parser.listen(Listener.new)
parser.parse
# >> [:start_document]
# >> [:xmldecl, "1.0", "UTF-8", nil]
# >> [:progress, 39]
# >> [:characters, "\n"]
# >> [:progre...
...ef=\"style.css\""]
# >> [:progress, 91]
# >> [:characters, "\n"]
# >> [:progress, 144]
# >> [:doctype, "root", "SYSTEM", "foo", nil]
# >> [:progress, 144]
# >> [:elementdecl, "<!ELEMENT root (a+)"]
# >> [:progress, 144]
# >> [:elementdecl, "<!ELEMENT a"]
# >> [:progress, 159]
# >> [:entitydecl, "bar...
..."barbarbarbar"]
# >> [:progress, 190]
# >> [:attlistdecl, "a", {"att"=>nil, "xyz"=>"foobar"}, " \n <!ATTLIST a att CDATA #REQUIRED xyz CDATA \"foobar\">"]
# >> [:progress, 245]
# >> [:notationdecl, "foobar", "SYSTEM", nil, "http://example.org/foobar.dtd"]
# >> [:progress, 683]
# >> [:entitydecl, "H...

絞り込み条件を変える

ruby 1.6 feature (306.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...Fixnum#>>, <<

負の数に対して右シフトすると 0 になることがありました。
((<ruby-bugs-ja:PR#247>))

負の数を引数にした左シフト(つまり右シフト)も同様におかしな挙動をして
いました。((<ruby-bugs-ja:PR#248>))

p(-1 >> 31)...
...ーになっていました。
((<ruby-dev:17155>))

open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end

}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3...
...トで 2 回シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))

trap(:TERM, "EXIT")

END
{
puts "exit"
}

Thread.start { Thread.stop }
sleep

: 2002-04-17: Regexp#inspect

((<ruby-bugs-ja:PR#222>))

p %r{\/}...

rexml/parsers/streamparser (198.0)

ストリーム式の XML パーサ。

...ener
include REXML::StreamListener
def initialize
@events = []
end


def text(text)
@events << "text[#{text}]"
end


def tag_start(name, attrs)
@events << "tag_start[#{name}]"
end


attr_reader :events
end


xml = <<EOS
<members>
<member name="apple" color="red">
<comme...
...args]
end

def respond_to_missing?(sym, include_private)
true
end

end


REXML::Parsers::StreamParser.new(xml, Listener.new).parse
# >> [:xmldecl, "1.0", "UTF-8", nil]
# >> [:text, "\n"]
# >> [:instruction, "xml-stylesheet", " type=\"text/css\" href=\"style.css\""]
# >> [:text, "\n"]
# >> [:d...
...oot", "SYSTEM", "foo", nil]
# >> [:elementdecl, "<!ELEMENT root (a+)"]
# >> [:elementdecl, "<!ELEMENT a"]
# >> [:entitydecl, ["bar", "barbarbarbar"]]
# >> [:attlistdecl, "a", {"att"=>nil, "xyz"=>"foobar"}, " \n <!ATTLIST a att CDATA #REQUIRED xyz CDATA \"foobar\">"]
# >> [:notationdecl, ["foobar",...

rexml/parsers/pullparser (180.0)

プル方式の XML パーサ。

...です。

: start_element (要素名, 属性)
XML要素の開始タグ。属性は { 属性名文字列 => 属性値文字列 } という Hash
: end_element (要素名)
XML要素の終了タグ
: text (正規化文字列, 非正規化文字列)
テキストノード
: processing_instruction (...
...別子 | nil, 公開識別子 | nil)
DTD 開始。判定は REXML::Parsers::PullEvent#doctype? メソッドで、
start_doctype? ではない
: end_doctype ()
DTD 終了
: attlistdecl (要素名, 属性名とデフォルト値, 宣言文字列)
DTDの属性リスト宣言。属性名とデ...
...p parser.pull
end

# >> xmldecl: ["1.0", "UTF-8", nil]
# >> text: ["\n", "\n"]
# >> processing_instruction: ["xml-stylesheet", " type=\"text/css\" href=\"style.css\""]
# >> text: ["\n", "\n"]
# >> start_doctype: ["root", "SYSTEM", "foo", nil]
# >> elementdecl: ["<!ELEMENT root (a+)"]
# >> elementdecl...

Range.new(first, last, exclude_end = false) -> Range (149.0)

first から last までの範囲オブジェクトを生成して返しま す。

...て返しま
す。

exclude_end が真ならば終端を含まない範囲オブジェクトを生
成します。exclude_end 省略時には終端を含みます。

@param first 最初のオブジェクト
@param last 最後のオブジェクト
@param exclude_end 真をセットした場合終...
...) # => 1...10
//}

//emlist[例: 日付オブジェクトの範囲オブジェクトの場合][ruby]{
require 'date'
Range.new(Date.today, Date.today >> 1).each {|d| puts d }
# => 2017-09-16
# 2017-09-17
# ...
# 2017-10-16
//}

//emlist[例: IPアドレスの範囲オブジェクトの場...
...のオブジェクトの場合][ruby]{
MyInteger = Struct.new(:value) do
def succ
self.class.new(value + 1)
end


def <=>(other)
value <=> other.value
end


def to_s
value.to_s
end

end

Range.new(MyInteger.new(1), MyInteger.new(3)).each {|i| puts i }
# => 1
# 2
# 3
//}...

演算子式 (120.0)

演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond

...! ~
**
-(単項)
* / %
+ -
<< >>
&
| ^
> >
= < <=
<=> == === != =~ !~
&&
||
.. ......
...単項演算子 +, - を表しメソッド定義
などではこの記法を利用します。


//emlist{
| ^ & <=> == === =~ > >= < <= << >>
+ - * / % ** ~ +@ -@ [] []= ` ! != !~
//}
これらの演算子式の定義方法についてはd:spec/def#operato...
...出しに変換されます。

//emlist[例][ruby]{
class C
def initialize
@ary = [0,1,2,3,4,5,6,7]
end

def [](i)
@ary[i * 2]
end

def []=( i, v )
@ary[i * 2] = v
end

end

c = C.new
p c[3] # c.[]( 3 ) に変換され、その結果は 6
p c[3] = 1 # c.[]=(3,1) に変換...

絞り込み条件を変える

<< 1 2 3 > >>