種類
- インスタンスメソッド (225)
- 特異メソッド (33)
- ライブラリ (22)
- 文書 (11)
ライブラリ
- ビルトイン (125)
-
irb
/ cmd / help (11) -
net
/ imap (11) -
rexml
/ document (33) - shell (24)
-
shell
/ command-processor (24) -
shell
/ filter (30)
クラス
-
Enumerator
:: Lazy (21) -
IRB
:: ExtendCommand :: Help (11) - Integer (16)
-
Net
:: IMAP :: FetchData (11) -
REXML
:: Element (22) -
REXML
:: XPath (11) -
RubyVM
:: InstructionSequence (44) - Shell (24)
-
Shell
:: CommandProcessor (24) -
Shell
:: Filter (30) - String (44)
キーワード
- [] (16)
-
absolute
_ path (11) - attr (11)
- cat (18)
- chunk (11)
- compile (11)
- each (11)
-
each
_ element _ with _ attribute (11) -
each
_ element _ with _ text (11) - echo (18)
- execute (11)
- glob (18)
- gsub (22)
- irb (11)
- new (11)
- path (11)
-
rexml
/ parsers / ultralightparser (11) -
ruby 1
. 6 feature (11) -
slice
_ when (10) - sub (22)
- tee (18)
検索結果
先頭5件
- irb
- Shell
:: Filter # >>(to) -> self - REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () - REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () - Enumerator
:: Lazy # slice _ when {|elt _ before , elt _ after| bool } -> Enumerator :: Lazy
-
irb (26096.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...irb は Interactive Ruby の略です。
irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
=== irb の使い方
Ruby さえ知っていれば irb を使うのは簡単です。
irb コマンドを実行すると、以下のようなプロン......ibrary ruby -r と同じ
-I ruby -I と同じ
-U ruby -U と同じ
-E enc ruby -E と同じ
--verbose これから実行する行を表示する
--noverbose これから実行する行を表示しない (デフォルト)
--ech......、空行を入力する事で irb のプロンプトに戻る事が
できます。
//emlist{
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)
---------... -
Shell
:: Filter # >>(to) -> self (24112.0) -
toをフィルタに追加する。 toが, 文字列ならばファイルに, IOオブジェクトであれば それをそのまま出力とする。
...に, IOオブジェクトであれば
それをそのまま出力とする。
@param to 出力先を指定します。文字列ならばファイルに、IOオブジェクトならばそれに出力します。
使用例
require 'shell'
Shell.def_system_command("tail")
sh = Shell.new
sh.tr......ansact {
(sh.tail("-n 3") < "/etc/passwd") >> "tail.out"
#(sh.tail("-n 3") < "/etc/passwd") >> File.open("tail.out", "w") # でも同じ。
}... -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (18342.0) -
特定の属性を持つすべての子要素を引数としてブロックを呼び出します。
...ます。
maxを指定すると、対象となる子要素の先頭 max 個のみが対象となります。
name を指定すると、それは xpath 文字列と見なされ、
それにマッチするもののみが対象となります。
max に 0 を指定すると、max の指定は無視さ......h文字列
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b id='1'/><c id='2'/><d id='1'/><e/></a>")
doc.root.each_element_with_attribute('id'){|e| p e }
# >> <b id='1'/>
# >> <c id='2'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1'){|e| p e }
# >> <b i......d='1'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1', 1){|e| p e }
# >> <b id='1'/>
doc.root.each_element_with_attribute('id', '1', 0, 'd'){|e| p e }
# >> <d id='1'/>
//}... -
REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () (18342.0) -
テキストを子ノードとして 持つすべての子要素を引数としてブロックを呼び出します。
...ます。
maxを指定すると、対象となる子要素の先頭 max 個のみが対象となります。
name を指定すると、それは xpath 文字列と見なされ、
それにマッチするもののみが対象となります。
max に 0 を指定すると、max の指定は無視さ......am name xpath文字列
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
doc.root.each_element_with_text {|e|p e}
# >> <b> ... </>
# >> <c> ... </>
# >> <d> ... </>
doc.root.each_element_with_text('b'){|e|p e}
# >> <b> ... </>
# >> <c> ... </......>
doc.root.each_element_with_text('b', 1){|e|p e}
# >> <b> ... </>
doc.root.each_element_with_text(nil, 0, 'd'){|e|p e}
# >> <d> ... </>
//}... -
Enumerator
:: Lazy # slice _ when {|elt _ before , elt _ after| bool } -> Enumerator :: Lazy (12230.0) -
Enumerable#slice_when と同じですが、配列ではなく Enumerator::Lazy を返します。
...erable#slice_when と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007fce84118348>:each>>
1.step.lazy.slice_when { |i, j| (i + j) %......5 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5, 6, 7], [8, 9, 10, 11, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22]]
//}
@see Enumerable#slice_when... -
rexml
/ parsers / ultralightparser (12072.0) -
パース結果を配列で作られた木構造により返すパーサ。
...返すパーサ。
REXML::Parsers::UltraLightParser.new でパーサオブジェクトを
生成し、REXML::Parsers::UltraLightParser#parse でパースし
その結果の木構造を返します。
===[a:nodes] ノードの表現
REXML::Parsers::UltraLightParser#parse が返す
XML の各ノー......素のように子ノードを持つ場合、
それらの子ノードもこの配列の要素として保持されます。
REXML::Parsers::UltraLightParser#parse の返り値となる
木のルートは特別で、ノードの種類を表すシンボルを持ちません。
XML宣言、DTD、ル....../emlist[][ruby]{
require 'rexml/parsers/ultralightparser'
require 'pp'
parser = REXML::Parsers::UltraLightParser.new(<<XML)
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<a n="1">xyz</a>
<b m="2" />
</root>
XML
pp parser.parse
# >> [[:xmldecl, "1.0", "UTF-8", nil],
# >> [:text, "\n"],
# >> [:... -
RubyVM
:: InstructionSequence # absolute _ path -> String | nil (9206.0) -
self が表す命令シーケンスの絶対パスを返します。
...は nil を返します。
例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... -
RubyVM
:: InstructionSequence # path -> String (9206.0) -
self が表す命令シーケンスの相対パスを返します。
...ompiled>" を返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
# => "<compiled>"
例2: RubyVM::InstructionSequence.compile_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... -
Shell
:: Filter # echo(*strings) -> Shell :: Filter (9206.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ilter オブジェクトを返します.
@param strings シェルコマンド echo に与える引数を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(fi......le).each { |l|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}... -
RubyVM
:: InstructionSequence . compile(source , file = nil , path = nil , line = 1 , options = nil) -> RubyVM :: InstructionSequence (6606.0) -
引数 source で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。
...にコンパイル済みの
RubyVM::InstructionSequence オブジェクトを作成して返します。
@param source Ruby のソースコードを文字列で指定します。
@param file ファイル名を文字列で指定します。
@param path 引数 file の絶対パスファイル名を......。
@param line 引数 source の 1 行目の行番号を指定します。
@param options コンパイル時のオプションを true、false、Hash オブ
ジェクトのいずれかで指定します。詳細は
RubyVM::InstructionSequence.compile_option= を参......照
してください。
RubyVM::InstructionSequence.compile("a = 1 + 2")
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
@see RubyVM::InstructionSequence.compile_file... -
Shell
:: Filter # cat(*files) -> Shell :: Filter (6306.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...る Filter オブジェクトを返します.
@param files シェルコマンド cat に与えるファイル名を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!......cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}...