るりまサーチ

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

別のキーワード

  1. module attr
  2. _builtin attr
  3. net/imap attr
  4. rdoc attr_modifiers
  5. etc sc_thread_attr_stackaddr

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 > >>

Module#attr_reader(*name) -> [Symbol] (18119.0)

インスタンス変数 name の読み取りメソッドを定義します。

...ンスタンス変数 name の読み取りメソッドを定義します。

//emlist[例][ruby]{
class
User
attr_reader
:name # => [:name]
# 複数の名前を渡すこともできる
attr_reader
:id, :age # => [:id, :age]
end
//}

このメソッドで定義されるメソッドの定義は...

ruby 1.6 feature (246.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...module_eval>)) のブロック内で定数やクラス変数のスコープが
変わることはなくなりました。((<ruby-dev:17876>))

class
Foo
FOO = 1
@@foo = 1
end

FOO = 2
@@foo = 2

Foo.module_eval { p FOO, @@foo }

=...
...列を返すようになった

: 2002-03-08 class variable

((<ruby-talk:35122>))

class
C
class
<< self
def test
@@cv = 5
p @@cv
end
end

test
end
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
fr...
...アクセサに余計な引数を渡してもエラーになりませんでした。
((<ruby-dev:13748>))

class
C
def initialize
@message = 'ok'
end
attr_reader
:message
end
puts C.new.message(1,2,3)

=> ruby 1.6.4 (2001-06-04) [i586-linux]
ok...

NEWS for Ruby 3.0.0 (96.0)

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

...d in singleton class definitions in methods is now a SyntaxError
instead of a warning. yield in a class definition outside of a method
is now a SyntaxError instead of a LocalJumpError. 15575
* When a class variable is overtaken by the same definition in an
ancestor class/module, a Run...
...timeError is now raised (previously,
it only issued a warning in verbose mode). Additionally, accessing a
class
variable from the toplevel scope is now a RuntimeError.
14541
* Assigning to a numbered parameter is now a SyntaxError instead of
a warning.

== Command line options

==...
...ic, Module#protected, Module#private, Module#public_class_method, Module#private_class_method, toplevel "private" and "public" methods now accept single array argument with a list of method names. 17314
* Module#attr_accessor, Module#attr_reader, Module#attr_writer and Module#attr methods now re...

NEWS for Ruby 3.1.0 (54.0)

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

...* Class
* 新規メソッド
* Class#subclassesはレシーバを継承した子クラスを要素に持つ配列(シングルトンクラスを含まない)を返します。

//emlist[Class#subclasses][ruby]{
class
A; end
class
B < A; end
class
C < B; end
class
D < A; end
A.subclasses...
...#=> [D, B]
B.subclasses #=> [C]
C.subclasses #=> []
//}

* Enumerable
* 新規メソッド
* Enumerable#compactが追加されました。 17312
* Enumerable#tallyがカウント集計用のハッシュオブジェクトを任意で渡せるようになりました。 1774...
...the `_Output` interface.
# `PrettyPrint[String]` is ok, but `PrettyPrint[Integer]` is a type error.
class
PrettyPrint[T < _Output]
interface _Output
def <<: (String) -> void
end

attr_reader
output: T

def initialize: (T output) -> void
end
//}

* ジェネリックな型エイリア...

Object.yaml_tag(tag) -> () (24.0)

クラスと tag の間を関連付けます。

...字列

=== Example
require 'psych'

class
Foo
def initialize(x)
@x = x
end

attr_reader
:x
end

# Dumps Ruby object normally
p Psych.dump(Foo.new(3))
# =>
# --- !ruby/object:Foo
# x: 3

# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013...
...:foo")
# ... and dumps the object of Foo class
Psych.dump(Foo.new(3), STDOUT)
# =>
# --- !<tag:example.com,2013:foo>
# x: 3

# Loads the object from the tagged YAML node
p Psych.load(<<EOS)
--- !<tag:example.com,2012:foo>
x: 8
EOS
# => #<Foo:0x0000000130f48 @x=8>...

絞り込み条件を変える

BasicObject#! -> bool (18.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...][ruby]{
class
NegationRecorder < BasicObject
def initialize
@count = 0
end
attr_reader
:count

def !
@count += 1
super
end
end

recorder = NegationRecorder.new
!recorder
!!!!!!!recorder
puts 'hoge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class
Anothe...

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

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

...さい。

//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 = "...

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

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

...さい。

//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 = "...

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

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

...せん。


//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 =...

rexml/parsers/streamparser (18.0)

ストリーム式の XML パーサ。

...rser'
require 'rexml/streamlistener'
class
Listener
include REXML::StreamListener
def initialize
@events = []
end

def text(text)
@events << "text[#{text}]"
end

def tag_start(name, attrs)
@events << "tag_start[#{name}]"
end

attr_reader
:events
end

xml = <<EOS
<members>...
...ar="http://example.org/bar"><![CDATA[cdata is here]]>
<a foo:att='1' bar:att='2' att='&lt;'/>
&amp;&amp; <!-- comment here--> &bar;
</root>
EOS

class
Listener
def method_missing(name, *args)
p [name, *args]
end
def respond_to_missing?(sym, include_private)
true
end
end

REXML::P...

絞り込み条件を変える

BasicObject#!=(other) -> bool (12.0)

オブジェクトが other と等しくないことを判定します。

...m other 比較対象となるオブジェクト
@see BasicObject#==, BasicObject#!

//emlist[例][ruby]{
class
NonequalityRecorder < BasicObject
def initialize
@count = 0
end
attr_reader
:count

def !=(other)
@count += 1
super
end
end
recorder = NonequalityRecorder.new

recorde...

Enumerable#max {|a, b| ... } -> object | nil (12.0)

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

...n 取得する要素数。

@raise TypeError ブロックが整数以外を返したときに発生します。

//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("...

Enumerable#max(n) {|a, b| ... } -> Array (12.0)

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

...n 取得する要素数。

@raise TypeError ブロックが整数以外を返したときに発生します。

//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("...
<< 1 2 3 > >>