438件ヒット
[1-100件を表示]
(0.016秒)
ライブラリ
- ビルトイン (278)
- csv (33)
- openssl (11)
- prettyprint (1)
-
rexml
/ document (22) - thread (2)
クラス
- CSV (33)
-
Enumerator
:: Lazy (60) - Object (44)
- PrettyPrint (1)
-
REXML
:: Attributes (22) - Range (11)
モジュール
- Enumerable (132)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - Lazy (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 3
. 0 . 0 (4) - OCSP (11)
- Queue (11)
- Range (11)
-
chunk
_ while (11) -
each
_ attribute (11) - eager (5)
-
enum
_ for (44) - first? (1)
- inject (33)
- new (22)
- parse (22)
- pp (11)
- reduce (33)
- rss (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
slice
_ before (22) -
slice
_ when (11) -
to
_ enum (44) - tsort (11)
検索結果
先頭5件
-
CSV
# each {|row| . . . } -> nil (18155.0) -
各行に対してブロックを評価します。
...ers = <<CSV
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
csv = CSV.new(users, headers: true)
csv.each do |row|
p row
end
# => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
# => #<CSV::Row "id":"2" "first name":"jiro" "......# => #<CSV::Row "id":"3" "first name":"ami" "last name":"sato" "age":"19">
# => #<CSV::Row "id":"4" "first name":"yumi" "last name":"adachi" "age":"21">
//}
//emlist[例 CSV.new 時に :header => true を指定しない場合][ruby]{
require "csv"
users = <<CSV
id,first name,last name,age
1,taro,......tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
csv = CSV.new(users)
csv.each do |row|
p row
end
# => ["id", "first name", "last name", "age"]
# => ["1", "taro", "tanaka", "20"]
# => ["2", "jiro", "suzuki", "18"]
# => ["3", "ami", "sato", "19"]
# => ["4", "yumi", "adachi", "21"]
//}... -
Enumerable
# first -> object | nil (18138.0) -
Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。
...引数を指定しない形式では nil を返します。
引数を指定する形式では、空の配列を返します。
@param n 取得する要素数。
//emlist[例][ruby]{
e = "abcd".each_byte
e.first #=> 97
e.first(2) #=> [97,98]
e = "".each_byte
e.first #=> nil
e.first(2) #=> []
//}... -
Enumerable
# first(n) -> Array (18138.0) -
Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。
...引数を指定しない形式では nil を返します。
引数を指定する形式では、空の配列を返します。
@param n 取得する要素数。
//emlist[例][ruby]{
e = "abcd".each_byte
e.first #=> 97
e.first(2) #=> [97,98]
e = "".each_byte
e.first #=> nil
e.first(2) #=> []
//}... -
REXML
:: Attributes # each {|name , value| . . . } -> () (18113.0) -
各属性の名前と値に対しブロックを呼び出します。
...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.each do |name, value|
p [name, value]
end
# => ["foo:att", "1"]
# => ["bar:att", "2"]
# => ["att", "<"]
//}... -
PrettyPrint
# first? -> bool (6119.0) -
このメソッドは obsolete です。
...です。
現在のグループで first? に対する最初の呼び出しかどうかを判定する
述語です。これはカンマで区切られた値を整形するのに有用です。
pp.group(1, '[', ']') {
xxx.each {|yyy|
unless pp.first?
pp.text ','
pp.bre... -
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (6113.0) -
各属性に対しブロックを呼び出します。
....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.each_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end
# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org... -
Range
. new(first , last , exclude _ end = false) -> Range (147.0) -
first から last までの範囲オブジェクトを生成して返しま す。
...
first から last までの範囲オブジェクトを生成して返しま
す。
exclude_end が真ならば終端を含まない範囲オブジェクトを生
成します。exclude_end 省略時には終端を含みます。
@param first 最初のオブジェクト
@param last 最後のオブ......ジェクト
@param exclude_end 真をセットした場合終端を含まない範囲オブジェクトを生成します
@raise ArgumentError first <=> last が nil の場合に発生します
//emlist[例: 整数の範囲オブジェクトの場合][ruby]{
Range.new(1, 10) # => 1..10
Rang......new(Date.today, Date.today >> 1).each {|d| puts d }
# => 2017-09-16
# 2017-09-17
# ...
# 2017-10-16
//}
//emlist[例: IPアドレスの範囲オブジェクトの場合][ruby]{
require 'ipaddr'
Range.new(IPAddr.new("192.0.2.1"), IPAddr.new("192.0.2.3")).each {|ip| puts ip}
# => 192.0.2.1
#... -
Object
# enum _ for(method = :each , *args) -> Enumerator (128.0) -
Enumerator.new(self, method, *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]{
modu......e
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (128.0) -
Enumerator.new(self, method, *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]{
modu......e
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42... -
Object
# to _ enum(method = :each , *args) -> Enumerator (128.0) -
Enumerator.new(self, method, *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]{
modu......e
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42...