るりまサーチ

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

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. class new
  5. argf.class gets

検索結果

<< 1 2 > >>

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

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

...d(: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 >> met...
...hod(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

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

Proc#>>(callable) -> Proc (18124.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#>>...

Object#singleton_class -> Class (6244.0)

レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。

...れ NilClass, TrueClass,
FalseClass を返します。

@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。

//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
nil.singleton_class...
...#=> NilClass
//}

@see Object#class...

ARGF.class#to_io -> IO (3018.0)

ARGFが現在開いているファイルのFile、またはIOオブジェクトを 返します。

...ARGFが現在開いているファイルのFile、またはIOオブジェクトを
返します。

ARGF.to_io # => #<File:glark.txt>
ARGF.to_io # => #<IO:<STDIN>>

@see ARGF.class#file, ARGF.class#to_write_io...

rexml/parsers/sax2parser (378.0)

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

...S

class
Listener
#include REXML::SAX2Listener
def method_missing(name, *args)
p [name, *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]
# >>...
...# >> [:progress, 39]
# >> [:characters, "\n"]
# >> [:progress, 91]
# >> [:processing_instruction, "xml-stylesheet", " type=\"text/css\" href=\"style.css\""]
# >> [:progress, 91]
# >> [:characters, "\n"]
# >> [:progress, 144]
# >> [:doctype, "root", "SYSTEM", "foo", nil]
# >> [:progress, 144]
# >> [...
...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]
# >> [:nota...

絞り込み条件を変える

ruby 1.6 feature (246.0)

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

...Fixnum#>>, <<

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

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

p(-1 >> 31)...
...module_eval>)) のブロック内で定数やクラス変数のスコープが
変わることはなくなりました。((<ruby-dev:17876>))

class
Foo
FOO = 1
@@foo = 1
end

FOO = 2
@@foo = 2

Foo.module_eval { p FOO, @@foo }

=...
...列を返すようになった

: 2002-03-08 class variable

((<ruby-talk:35122>))

class
C
class
<< self
def test
@@cv = 5
p @@cv
end
end

test
end
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
fr...

rexml/parsers/streamparser (150.0)

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

...意してください。

//emlist[][ruby]{
require 'rexml/parsers/baseparser'
require 'rexml/parsers/streamparser'
require 'rexml/streamlistener'
class
Listener
include REXML::StreamListener
def initialize
@events = []
end

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

def tag_...
...> &bar;
</root>
EOS

class
Listener
def method_missing(name, *args)
p [name, *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, "x...
...stylesheet", " type=\"text/css\" href=\"style.css\""]
# >> [:text, "\n"]
# >> [:doctype, "root", "SYSTEM", "foo", nil]
# >> [:elementdecl, "<!ELEMENT root (a+)"]
# >> [:elementdecl, "<!ELEMENT a"]
# >> [:entitydecl, ["bar", "barbarbarbar"]]
# >> [:attlistdecl, "a", {"att"=>nil, "xyz"=>"foobar"}, " \...

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

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

..."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
# >> X2

# 2つのモジュールを X, Y を prepend X, Y と...
...y)
end
end

class
B
prepend X, Y
def foo
puts "B" # (1b)
end
end

B.new.foo
# (1x) (2x) (1y) (2y) (1b) (3y) (3x) の順に実行される
# X#foo のほうが Y#foo より継承チェインの手前側にあり、そちらが優先される
# >> X1
# >> Y1
# >> B
# >> Y2
# >> X2
# prepen...

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (48.0)

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or  plus minus ast slash hat sq  period comma langl rangl eq tilde  dollar at under lbrarbra  lbra2rbra2 lbra3rbra3 dq colon ac  backslash semicolon

...でを文字列とする行指向のリテラルです。

: class Foo < Super

クラス定義でスーパークラスを指定しています。
d:spec/def#class

: class << obj

特異クラス定義。d:spec/def#singleton_classを参照。

===[a:rangl] >

: 3 > 5

「より大きい」...
...れば -1
を返すように作ることが期待されています。

: 3 >> 1

シフト演算子。または類似のメソッド。

: a >>= 1

>>」演算子の自己代入演算子。
//emlist{
a = 3
a >>= 1
p a #=> 1
//}

: { 1 => "11" , 3 => "333" }

ハッシュのリテラル...
...。d:spec/variables#instanceを参照。

: @@xxx

クラス変数。d:spec/variables#classを参照。

: def +@ または def -@

単項演算子 +X や -X を定義するときの表記法。
//emlist{
class
Symbol
def +@
self.upcase
end
end

puts(+:joke) #=> JOKE
//}

===[a...

REXML::StreamListener#entitydecl(content) -> () (42.0)

DTDの実体宣言をパースしたときに呼び出されるコールバックメソッドです。

..." NDATA gif>
]>
<root />
EOS

class
Listener
include REXML::StreamListener
def entitydecl(content); p content; end
end
REXML::Parsers::StreamParser.new(xml, Listener.new).parse
# >> ["YN", "\"Yes\"", "%"]
# >> ["YN", "Yes", "%"]
# >> ["WhatHeSaid", "He said %YN;"]
# >> ["open-hatch", "SYSTEM", "...
...http://www.textuality.com/boilerplate/OpenHatch.xml"]
# >> ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
# >> ["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "gif"]
//}...

絞り込み条件を変える

<< 1 2 > >>