539件ヒット
[501-539件を表示]
(0.147秒)
ライブラリ
- ビルトイン (57)
- psych (22)
-
rdoc
/ parser / c (11) -
rdoc
/ parser / changelog (11) -
rdoc
/ parser / markdown (11) -
rdoc
/ parser / rd (11) -
rdoc
/ parser / ruby (11) -
rdoc
/ parser / simple (11) - scanf (42)
- strscan (341)
-
webrick
/ httpserver (11)
クラス
- Enumerator (11)
- Method (12)
- Proc (12)
-
Psych
:: ScalarScanner (22) -
RDoc
:: Parser :: C (11) -
RDoc
:: Parser :: ChangeLog (11) -
RDoc
:: Parser :: Markdown (11) -
RDoc
:: Parser :: RD (11) -
RDoc
:: Parser :: Ruby (11) -
RDoc
:: Parser :: Simple (11) -
Scanf
:: FormatSpecifier (6) -
Scanf
:: FormatString (24) - String (22)
- StringScanner (341)
-
WEBrick
:: HTTPServer :: MountTable (11)
モジュール
- Kernel (12)
キーワード
- << (23)
- >> (12)
- [] (11)
-
beginning
_ of _ line? (11) - bol? (11)
- check (11)
-
check
_ until (11) - clear (11)
- concat (11)
- each (11)
- empty? (11)
- eos? (11)
- exist? (11)
-
get
_ byte (11) - getbyte (11)
- getch (11)
- gsub (11)
-
last
_ match _ tried (6) -
last
_ spec (6) -
last
_ spec _ tried (6) - letter (6)
- match? (11)
- matched (11)
- matched? (11)
-
matched
_ size (11) - matchedsize (11)
-
parse
_ time (11) -
post
_ match (11) -
pre
_ match (11) - reset (11)
- rest? (11)
-
scan
_ full (11) -
scan
_ until (11) - scanf (12)
-
search
_ full (11) - skip (11)
-
skip
_ until (11) -
string
_ left (6) - terminate (11)
- tokenize (11)
- unscan (11)
検索結果
先頭5件
-
Enumerator
# each -> self (131.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...たイテレータの戻り値をそのまま返します。
@param args 末尾へ追加する引数
//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"......tr.scan(/\w+/) {|word| p word } # => "Yet"
# "Another"
# "Ruby"
# "Hacker"
//}
//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello",......"world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x... -
Method
# <<(callable) -> Proc (107.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します......なります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
def f(x)
x * x
end
def g(x)
x + x
end
# (3 + 3) * (3 + 3)
p (method(:f) << method(:g)).call(3) # => 36
//}
//emlist[call を定義したオブジェ......を渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = method(:pp) << WordScanner << File.method(:read)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Pro... -
Method
# >>(callable) -> Proc (107.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します......なります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][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 Pro... -
Proc
# <<(callable) -> Proc (107.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します......allable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }
# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScan......ner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}
@see Method#<<, Method#>>... -
Proc
# >>(callable) -> Proc (107.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します......allable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }
# (3 * 3) + (3 * 3)
p (f >> g).call(3) # => 18
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScan......ner
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#>>... -
String
# gsub(pattern , replace) -> String (102.0) -
文字列中で pattern にマッチする部分全てを 文字列 replace で置き換えた文字列を生成して返します。
...文字列中で pattern にマッチする部分全てを
文字列 replace で置き換えた文字列を生成して返します。
置換文字列 replace 中の \& と \0 はマッチした部分文字列に、
\1 ... \9 は n 番目の括弧の内容に置き換えられます。
置換文字......。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列
//emlist[例][ruby]{
p 'abcdefg'.gsub(/def/, '!!') # => "abc!!g"
p 'abcabc'.gsub(/b/, '<<\&>>') # => "a......<<b>>ca<<b>>c"
p 'xxbbxbb'.gsub(/x+(b+)/, 'X<<\1>>') # => "X<<bb>>X<<bb>>"
p '2.5'.gsub('.', ',') # => "2,5"
//}
注意:
第 2 引数 replace に $1 を埋め込んでも意図した結果にはなりません。
この文字列が評価される時点ではまだ正規表現マッチが行われ...