種類
- 特異メソッド (309)
- インスタンスメソッド (167)
- 文書 (97)
- ライブラリ (55)
- モジュール関数 (22)
ライブラリ
- ビルトイン (128)
- csv (165)
- json (55)
-
json
/ add / struct (11) - ostruct (21)
- pstore (22)
- rake (22)
-
rexml
/ document (44) - win32ole (11)
-
yaml
/ store (19)
クラス
- CSV (165)
- Data (8)
- IO (88)
-
JSON
:: Parser (11) - OpenStruct (21)
- PStore (22)
-
REXML
:: Attributes (11) -
REXML
:: Element (11) -
REXML
:: XPath (22) -
Rake
:: TaskArguments (22) - Struct (43)
- WIN32OLE (11)
-
YAML
:: Store (19)
モジュール
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - Ruby用語集 (11)
- [] (1)
-
add
_ attributes (11) - cgi (11)
-
cgi
/ session (11) -
deconstruct
_ keys (2) - delete (11)
- dig (9)
- each (11)
- fetch (11)
- filter (33)
- generate (22)
- hash (13)
- instance (22)
- invoke (11)
- match (11)
- namespaces (11)
- open (44)
- parse (22)
- popen (88)
- rdoc (11)
- read (11)
- readlines (11)
- rss (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) -
to
_ h (33) -
to
_ hash (11) -
to
_ json (33) - unparse (11)
-
webrick
/ cgi (11) -
with
_ defaults (11)
検索結果
先頭5件
-
CSV
. new(data , options = Hash . new) -> CSV (18363.0) -
このメソッドは CSV ファイルを読み込んだり、書き出したりするために String か IO のインスタンスをラップします。
...EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
File.write("test.csv", users)
File.open("test.csv", "r") do |f|
csv = CSV.new(f, headers: true)
csv.class # => CSV
csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka"......equire "csv"
users =<<-EOS
id|first name|last name|age
1|taro|tanaka|20
2|jiro|suzuki|18
3|ami|sato|19
4|yumi|adachi|21
EOS
csv = CSV.new(users, headers: true, col_sep: "|")
p csv.class # => CSV
p csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
//}
@see CSV... -
YAML
:: Store . new(file _ name , thread _ safe = false , yaml _ opts = {}) -> YAML :: Store (18216.0) -
自身を初期化します。
...自身を初期化します。
@param file_name 格納先のファイル名。ファイルがない場合は作成します。既
にファイルが存在する場合はその内容を読み込みます。
@param thread_safe 自身をスレッドセーフにして初期化する......かどうか。
@param yaml_opts YAML 出力時のオプションを Hash で指定します。
詳しくは Psych.dump を参照してください。... -
YAML
:: Store . new(file _ name , yaml _ opts = {}) -> YAML :: Store (18216.0) -
自身を初期化します。
...化します。
@param file_name 格納先のファイル名。ファイルがない場合は作成します。既
にファイルが存在する場合はその内容を読み込みます。
@param yaml_opts YAML 出力時のオプションを Hash で指定します。......自身を初期化します。
@param file_name 格納先のファイル名。ファイルがない場合は作成します。既
にファイルが存在する場合はその内容を読み込みます。
@param thread_safe 自身をスレッドセーフにして初期化する......かどうか。
@param yaml_opts YAML 出力時のオプションを Hash で指定します。
詳しくは Psych.dump を参照してください。... -
JSON
:: Parser . new(source , options => {}) -> JSON :: Parser (18161.0) -
パーサを初期化します。
...せん。デフォルトは真です。
: :object_class
JSON のオブジェクトを変換するクラスを指定します。デフォルトは Hash です。
: :array_class
JSON の配列を変換するクラスを指定します。デフォルトは Array です。
@param source パーサ......::Parser.new(DATA.read)
print parser.source
# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki": {
# => "name":"suzuki",
# => "age":25
# => }
# => }
__END__
{
"Tanaka": {
"name":"tanaka",
"age":20
},
"Suzuki": {
"name":"suzuki......on
attr_accessor :name, :age
def []=(key, value)
instance_variable_set("@#{key}", value)
end
end
parser = JSON::Parser.new(DATA.read, object_class: Person)
person = parser.parse
person.class # => Person
person.name # => "tanaka"
person.age # => 20
__END__
{
"name":"tanaka",
"age"... -
Struct
. new(*args , keyword _ init: nil) -> Class (15273.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
...アクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス名の省略は後......emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2) # => #<struct Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unkn......{
Point = Struct.new(:x, :y)
Point.new(x: 1, y: 2) # => #<struct Point x={:x=>1, :y=>2}, y=nil>
# warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
# keywor... -
Struct
. new(*args , keyword _ init: nil) {|subclass| block } -> Class (15273.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
...アクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス名の省略は後......emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2) # => #<struct Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unkn......{
Point = Struct.new(:x, :y)
Point.new(x: 1, y: 2) # => #<struct Point x={:x=>1, :y=>2}, y=nil>
# warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
# keywor... -
Struct
. new(*args) -> Struct (15143.0) -
(このメソッドは Struct の下位クラスにのみ定義されています) 構造体オブジェクトを生成して返します。
...なければ nil です。
@return 構造体クラスのインスタンス。
@raise ArgumentError 構造体のメンバの数よりも多くの引数を指定した場合に発生します。
//emlist[例][ruby]{
Foo = Struct.new(:foo, :bar)
foo = Foo.new(1)
p foo.values # => [1, nil]
//}... -
Rake
:: TaskArguments # to _ hash -> Hash (6238.0) -
パラメータ名と対応する値を格納したハッシュを返します。
...納したハッシュを返します。
//emlist[][ruby]{
# Rakefile での記載例とする
task default: :test_rake_app
task :test_rake_app do
arguments = Rake::TaskArguments.new(["name1", "name2"], ["value1", "value2"])
arguments.to_hash # => {:name1=>"value1", :name2=>"value2"}
end
//}... -
NEWS for Ruby 2
. 6 . 0 (6186.0) -
NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.6.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......と :order を受け付けるようになりました。 14324
* Hash
* 変更されたメソッド
* Hash#merge, Hash#merge!, Hash#update が引数を複数受け付けるようになりました。 15111
* Hash#to_h はブロックを受け取りキーと値のペアを新し......チェックします。
それ以外の場合はそのクラス自身のみチェックします。 14944
* NameError
* 新規オプション
* NameError.new に :receiver オプションが追加されて
Ruby コードからも設定できるようになりました。... -
Data
# hash -> Integer (6149.0) -
自身のハッシュ値を整数で返します。 Data#eql? で比較して等しいオブジェクトは同じハッシュ値を返します。
...を返します。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5)
p dog1.hash # => -3931425561194935428
dog2 = Dog.new("Fred", 5)
p dog2.hash # => -3931425561194935428
dog3 = Dog.new("Fred", 6)
p dog3.hash # => -4469132459285820530
//}
[注意] 本メソッドの記......述は Data のサブクラスのインスタンスに対して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。
@see Object#hash... -
NEWS for Ruby 3
. 0 . 0 (6144.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 3.0.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......eturns a hash excluding the given keys and their values. 15822
* Windows: Read ENV names and values as UTF-8 encoded Strings 12650
* Encoding
* Added new encoding IBM720. 16233
* Changed default for Encoding.default_external to UTF-8 on Windows 16604
* Fiber
* Fiber.new(blockin......cant overhead to major collections, so please test first! 17176
* Hash
* Hash#transform_keys and Hash#transform_keys! now accept a hash that maps keys to new keys. 16274
* Hash#except has been added, which returns a hash excluding the given keys and their values. 15822
* IO
* IO#n... -
Struct
# hash -> Integer (6143.0) -
self が保持するメンバのハッシュ値を元にして算出した整数を返します。 self が保持するメンバの値が変化すればこのメソッドが返す値も変化します。
....new(:name, :age)
dog = Dog.new("fred", 5)
p dog.hash #=> 7917421
dog.name = "john"
p dog.hash #=> -38913223
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new... -
NEWS for Ruby 2
. 7 . 0 (6132.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.7.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......END
{
"name": "Alice",
"age": 30,
"children": [{ "name": "Bob", "age": 2 }]
}
END
JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: name, age: age}]}
p name #=> "Bob"
p age #=> 2
JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charli......のプラットフォームでrealpath(3)を使います。
これは大幅にパフォーマンスを改善します。 15797
* Hash
* 小さいHashオブジェクトのデータ構造が変わりました。 15602
* Monitor
* MonitorクラスがC拡張になりました。 1625... -
NEWS for Ruby 2
. 5 . 0 (6120.0) -
NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.5.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......File.stat, File.exist? など rb_stat() を使用しているメソッドではGVLを解放するようになりました
13941
* File.rename GVL を解放するようになりました 13951
* File::Stat#atime, File::Stat#mtime, File::Stat#ctime
Windows 8 以降でタイムス......ime, File.lstat はGVLを解放するようになりました
* File.lutime を追加 4052
* Hash
* Hash#transform_keys を追加 13583
* Hash#transform_keys! を追加 13583
* Hash#slice を追加 8499
* IO
* IO.copy_stream は copy_file_range(2) を使うようになり... -
REXML
:: Attributes # namespaces -> { String => String } (6112.0) -
self の中で宣言されている名前空間の集合を返します。
...の集合を返します。
返り値は名前空間の prefix をキーとし、URI を値とする
Hash を返します。
//emlist[][ruby]{
require '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
p doc.root.attributes.namespaces
# => {"foo"=>"http://example.org/foo", "bar"=>"http://example.org/bar"}
p a.attributes.namespaces
# => {}
//}...