1245件ヒット
[201-300件を表示]
(0.332秒)
ライブラリ
- ビルトイン (778)
-
cgi
/ core (24) - csv (186)
- date (4)
- forwardable (24)
- prettyprint (1)
- psych (12)
-
rexml
/ document (216)
クラス
- Array (48)
- CSV (132)
-
CSV
:: FieldInfo (24) -
CSV
:: Row (30) - Date (2)
- DateTime (2)
-
Enumerator
:: ArithmeticSequence (14) -
Enumerator
:: Lazy (90) -
File
:: Stat (12) - Object (48)
- PrettyPrint (1)
-
Psych
:: Handler (12) -
REXML
:: Attributes (144) -
REXML
:: Element (36) -
REXML
:: Parent (24) - Range (118)
-
RubyVM
:: AbstractSyntaxTree :: Node (14) -
RubyVM
:: InstructionSequence (24) - String (216)
-
Thread
:: Backtrace :: Location (36) - Time (2)
モジュール
-
CGI
:: QueryExtension :: Value (24) - Enumerable (156)
- Forwardable (24)
-
REXML
:: Node (12)
キーワード
- << (12)
- <=> (12)
- [] (84)
- []= (36)
-
add
_ row (12) - alias (12)
- attribute (12)
- begin (12)
-
chunk
_ while (12) -
col
_ sep (12) - convert (36)
- deconstruct (3)
-
deconstruct
_ keys (9) - delegate (12)
- delete (12)
-
delete
_ all (12) - each (24)
-
each
_ attribute (12) - eager (6)
- end (12)
-
enum
_ for (48) - fields (12)
-
find
_ first _ recursive (12) - first? (1)
-
first
_ column (7) -
first
_ lineno (19) -
get
_ attribute (12) -
get
_ attribute _ ns (12) - header (12)
-
header
_ convert (36) - index (12)
- inject (36)
-
insert
_ after (12) -
insert
_ before (12) -
instance
_ delegate (12) - label (12)
- last (48)
- lazy (12)
- length (12)
- lineno (12)
- min (46)
- namespaces (12)
- path (12)
- prefixes (12)
- puts (12)
- reduce (36)
- root (12)
-
root
_ node (12) - size (12)
- slice (72)
- slice! (72)
-
slice
_ before (24) -
slice
_ when (12) - take (12)
-
take
_ while (24) -
to
_ a (12) -
to
_ enum (48) -
values
_ at (12)
検索結果
先頭5件
-
Enumerable
# slice _ when {|elt _ before , elt _ after| bool } -> Enumerator (9107.0) -
要素を前から順にブロックで評価し、その結果によって要素をチャンクに分け た(グループ化した)要素を持つEnumerator を返します。
...た)要素を持つEnumerator を返します。
隣り合う値をブロックパラメータ elt_before、elt_after に渡し、ブロックの
評価値が真になる所でチャンクを区切ります。
ブロックは self の長さ - 1 回呼び出されます。
@return チャンクご...... Enumerator
を返します。eachメソッドは以下のように呼び出します。
//emlist{
enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... }
//}
to_a や map などのその他の Enumerable モジュールのメソッ
ドも有用です。
//emli......分配列ごとに分ける。
a = [1,2,4,9,10,11,12,15,16,19,20,21]
b = a.slice_when {|i, j| i+1 != j }
p b.to_a # => [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]]
c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" }
p c # => [[1, 2], [4], "9-12", [15, 16], "19-21"]
d = c.join(",")
p... -
Enumerable
# inject(init = self . first) {|result , item| . . . } -> object (6303.0) -
リストのたたみこみ演算を行います。
...ストのたたみこみ演算を行います。
最初に初期値 init と self の最初の要素を引数にブロックを実行します。
2 回目以降のループでは、前のブロックの実行結果と
self の次の要素を引数に順次ブロックを実行します。
そうし......の result の値です。任意のオブジェクトが渡せます。
@param sym ブロックの代わりに使われるメソッド名を表す Symbol オブジェクトを指定します。
実行結果に対して sym という名前のメソッドが呼ばれます。
//emlist[......ject {|result, item| result + item } #=> 14
# 自乗和を計算する。初期値をセットする必要がある。
p [2, 3, 4, 5].inject(0) {|result, item| result + item**2 } #=> 54
//}
この式は以下のように書いても同じ結果が得られます。
//emlist[例][ruby]{
re... -
CSV
:: Row # deconstruct -> [object] (6213.0) -
パターンマッチに使用する行の値の配列を返します。
...//emlist[例][ruby]{
require "csv"
row = CSV::Row.new(["header1", "header2", "header3"], [1, 2, 3])
case row
in [2.., 2.., 2..]
puts "all 2 or more"
in [...2, 2.., 2..]
puts "first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than 2, and rest columns are 2......or more" が出力される
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
REXML
:: Element # root _ node -> REXML :: Document | REXML :: Node (6213.0) -
self が属する文書のルートノードを返します。
...self が属する文書のルートノードを返します。
通常はその要素が属する文書(REXML::Document) オブジェクトが
返されます。
その要素が属する REXML::Document オブジェクトが存在しない
場合は木構造上のルートノードが返されま......。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root>
<children>
<grandchildren />
</children>
</root>
EOS
children = doc.get_elements("/root/children").first
children.name # => "children"
children.root_node == doc # => true
grandchildren = doc.get_elements("/roo......t/children/grandchildren").first
grandchildren.name # => "grandchildren"
grandchildren.root_node == doc # => true
//}... -
CSV
:: Row # values _ at(*headers _ and _ or _ indices) -> Array (6207.0) -
与えられた引数に対応する値の配列を返します。
...えられた引数に対応する値の配列を返します。
要素の探索に CSV::Row#field を使用しています。
@param headers_and_or_indices ヘッダの名前かインデックスか Range
のインスタンスか第 1 要素がヘッダの名前で......るこ
とができます。
@return 引数を与えなかった場合は全ての要素を返します。
require 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
table = csv.read
row = table.first
row.values_at("a", 1, 2..3) # => ["1", "2", "3", nil]... -
Object
# enum _ for(method = :each , *args) -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......ef repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
e... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......ef repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
e... -
Object
# to _ enum(method = :each , *args) -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......ef repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
e... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......ef repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
e... -
REXML
:: Attributes # delete(attribute) -> REXML :: Element (6207.0) -
指定した属性を取り除きます。
...ute で取り除く属性を指定します。
文字列もしくは REXML::Attribute オブジェクトを指定します
self が属する要素(REXML::Element)を返します。
@param attribute 取り除く属性(文字列もしくは REXML::Attribute オブジェクト)
//emlist[][ruby]{
req......uire 'rexml/document'
doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' att='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
a.attributes.delete("att") # => <a foo:att='1' bar:att='2'/>
a.......attributes.delete("foo:att") # => <a bar:att='2'/>
attr = a.attributes.get_attribute("bar:att")
a.attributes.delete(attr) # => <a/>
//}...