るりまサーチ

最速Rubyリファレンスマニュアル検索!
345件ヒット [1-100件を表示] (0.144秒)
トップページ > クエリ:i[x] > クエリ:end[x] > クエリ:attr[x] > クエリ:new[x]

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. matchdata end

検索結果

<< 1 2 3 ... > >>

ERB.new(str, safe_level=NOT_GIVEN, trim_mode=NOT_GIVEN, eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: &#39;_erbout&#39;) -> ERB (18467.0)

eRubyスクリプト から ERB オブジェクトを生成して返します。

...

@param str eRubyスクリプトを表す文字列
@param safe_level eRubyスクリプトが実行されるときのセーフレベル
@param trim_mode 整形の挙動を変更するオプション

@param eoutvar eRubyスクリプトの中で出力をためていく変数の名前を表す文...
...

//emlist[例][ruby]{
require "erb"

# build data class
class Listings
PRODUCT = { :name => "Chicken Fried Steak",
:desc => "A well messages pattie, breaded and fried.",
:cost => 9.95 }

attr
_reader :product, :price

def initialize( product = "", price = "" )...
...t
@price = price
end


def build
b = binding
# create and run templates, filling member data variables
ERB.new(<<~'END_PRODUCT', eoutvar: "@product").result b
<%= PRODUCT[:name] %>
<%= PRODUCT[:desc] %>
END
_PRODUCT
ERB.new(<<~'END_PRICE', eoutvar: "@price").res...

REXML::Attributes#each_attribute {|attribute| ... } -> () (18436.0)

各属性に対しブロックを呼び出します。

...:Attribute オブジェクトで渡されます。

//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='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a").fi...
...rst

a.attributes.each_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end

# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}...

ERB.new(str, safe_level=nil, trim_mode=nil, eoutvar=&#39;_erbout&#39;) -> ERB (18367.0)

eRubyスクリプト から ERB オブジェクトを生成して返します。

...

@param str eRubyスクリプトを表す文字列
@param safe_level eRubyスクリプトが実行されるときのセーフレベル
@param trim_mode 整形の挙動を変更するオプション

@param eoutvar eRubyスクリプトの中で出力をためていく変数の名前を表す文...
...

//emlist[例][ruby]{
require "erb"

# build data class
class Listings
PRODUCT = { :name => "Chicken Fried Steak",
:desc => "A well messages pattie, breaded and fried.",
:cost => 9.95 }

attr
_reader :product, :price

def initialize( product = "", price = "" )...
...uct
@price = price
end


def build
b = binding
# create and run templates, filling member data variables
ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), 0, "", "@product").result b
<%= PRODUCT[:name] %>
<%= PRODUCT[:desc] %>
END
_PRODUCT
ERB.new(<<-'END_PRICE'.gsub(/...

ERB.new(str, trim_mode: nil, eoutvar: &#39;_erbout&#39;) -> ERB (18267.0)

eRubyスクリプト から ERB オブジェクトを生成して返します。

...eRubyスクリプト から ERB オブジェクトを生成して返します。

@param str eRubyスクリプトを表す文字列
@param trim_mode 整形の挙動を変更するオプション

@param eoutvar eRubyスクリプトの中で出力をためていく変数の名前を表す文...
...


//emlist[例][ruby]{
require "erb"

# build data class
class Listings
PRODUCT = { :name => "Chicken Fried Steak",
:desc => "A well messages pattie, breaded and fried.",
:cost => 9.95 }

attr
_reader :product, :price

def initialize( product = "", price = "" )...
...t
@price = price
end


def build
b = binding
# create and run templates, filling member data variables
ERB.new(<<~'END_PRODUCT', eoutvar: "@product").result b
<%= PRODUCT[:name] %>
<%= PRODUCT[:desc] %>
END
_PRODUCT
ERB.new(<<~'END_PRICE', eoutvar: "@price").res...

JSON::Parser.new(source, options => {}) -> JSON::Parser (18243.0)

パーサを初期化します。

...: :max_nesting
データ構造のネストの深さの最大値を指定します。デフォルトは 19 です。
チェックを無効にするにはゼロまたは偽を指定してください。
: :allow_nan
真を指定すると 4627 を無視して NaN, Infinity, -Infinity をパー...
...aram options オプションを指定するためのハッシュです。

//emlist[例][ruby]{
require 'json'

parser = JSON::Parser.new(DATA.read)
print parser.source

# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki": {
# => "name":"suzuki",
# =>...
..._END__
{
"Tanaka": {
"name":"tanaka",
"age":20
},
"Suzuki": {
"name":"suzuki",
"age":25
}
}
//}

//emlist[例 object_class を指定する][ruby]{
require 'json'

class Person
attr
_accessor :name, :age

def []=(key, value)
i
nstance_variable_set("@#{key}", value)
end
...

絞り込み条件を変える

Thread::Backtrace::Location#inspect -> String (6236.0)

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。

...race::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。

//emlist[例][ruby]{
# foo.rb
class Foo
attr
_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end

end


Foo.new(0..2).locations.map do...
...|call|
puts call.inspect
end


# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "path/to/foo.rb:9:in `<main>'"
//}...

Tracer.set_get_line_procs(filename) {|line| .... } (6230.0)

あるファイルについて利用する、行番号からソースのその行の内容を返す 手続きを指定します。何も指定しなければデフォルトの動作が利用されます。 指定する手続きは行番号を唯一の引数として呼び出されます。

...@param filename ソースファイルの場所を文字列で指定します。
@param proc 通常、文字列を返す手続きオブジェクトを指定します。

# 例 dummy.rb の3行目から6 行目のトレース出力に !! をつける
require 'tracer'

Tracer.set_get_line_procs(...
...'./dummy.rb'){|line|
str = "\n"
str = "!!\n" if line >= 3 and line <= 6
str
}
Tracer.on
require 'dummy'

dm = Dummy.new
puts dm.number

=begin
# dummy.rb
class Dummy
def initialize
@number = 135
end

attr
:number
end

=end...

cgi (6192.0)

CGI プログラムの支援ライブラリです。

...CGI プログラムの支援ライブラリです。

CGI プロトコルの詳細については以下の文書を参照してください。

* https://tools.ietf.org/html/draft-coar-cgi-v11-03
* 3875: The Common Gateway Interface (CGI) Version 1.1
* https://www.w3.org/CGI/

=== 使用例

=...
...ist[][ruby]{
require "cgi"
cgi = CGI.new
values = cgi['field_name'] # <== 'field_name' の配列
# 'field_name' が指定されていなかったら、 ""を返す。
fields = cgi.keys # <== field nameの配列

# フォームに 'field_name' というfield nameがあるときに真
cgi...
...使うのが最も簡単です。

//emlist[][ruby]{
# 保存
require 'pstore'
db = PStore.new("query.db")
db.transaction do
db["params"] = cgi.params
end


# 復帰
require 'pstore'
db = PStore.new("query.db")
db.transaction do
cgi.params = db["params"]
end

//}

ただし、PStore は Ruby の...

Enumerable#min {|a, b| ... } -> object | nil (6172.0)

ブロックの評価結果で各要素の大小判定を行い、最小の要素、もしくは最小の n 要素が昇順で入った配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。

...素、もしくは最小の
n 要素が昇順で入った配列を返します。
引数を指定しない形式では要素が存在しなければ nil を返します。
引数を指定する形式では、空の配列を返します。

ブロックの値は、a > b のとき正、a == b のと...
.../emlist[例][ruby]{
class Person
attr
_reader :name, :age

def initialize(name, age)
@name = name
@age = age
end

end


people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 1...
...1),
Person.new("tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 11)
]

# 年齢が最小、名前が最大
people.min { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fd6f0824190 @name="tanaka", @age=11>

people.min(2) { |x, y| (x.age <=> y.age).nonzer...

Enumerable#min(n) {|a, b| ... } -> Array (6172.0)

ブロックの評価結果で各要素の大小判定を行い、最小の要素、もしくは最小の n 要素が昇順で入った配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。

...素、もしくは最小の
n 要素が昇順で入った配列を返します。
引数を指定しない形式では要素が存在しなければ nil を返します。
引数を指定する形式では、空の配列を返します。

ブロックの値は、a > b のとき正、a == b のと...
.../emlist[例][ruby]{
class Person
attr
_reader :name, :age

def initialize(name, age)
@name = name
@age = age
end

end


people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 1...
...1),
Person.new("tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 11)
]

# 年齢が最小、名前が最大
people.min { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fd6f0824190 @name="tanaka", @age=11>

people.min(2) { |x, y| (x.age <=> y.age).nonzer...

絞り込み条件を変える

JSON.create_id -> String (6148.0)

json_create メソッドで使用するクラスを決定するために使用する値を返します。

...

//emlist[例][ruby]{
require "json"

class User
attr
:id, :name
def initialize(id, name)
@id, @name = id, name
end


def self.json_create(object)
new
(object['id'], object["name"])
end


def as_json(*)
{
JSON.create_id => self.class.name,
"id" => id,
"name...
..." => name,
}
end


def to_json(*)
as_json.to_json
end

end


json = JSON.generate(User.new(1, "tanaka"))
json # => "{\"json_class\":\"User\",\"id\":1,\"name\":\"tanaka\"}"
JSON.parse(json, create_additions: true)
# => #<User:0x0000557709b269e0 @id=1, @name="tanaka">
//}...

NEWS for Ruby 3.0.0 (6144.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 3.0.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs
accepting...
...tion warning
# 3.0 => a=>1}, {}]
//}

* Arguments forwarding (`...`) now supports leading arguments.
16378

//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end

//}

* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesig...
<< 1 2 3 ... > >>