種類
- インスタンスメソッド (172)
- 文書 (41)
- 特異メソッド (24)
- ライブラリ (12)
ライブラリ
- ビルトイン (124)
- erb (12)
- forwardable (24)
- psych (12)
- win32ole (24)
クラス
- BasicObject (24)
- ERB (12)
- Module (4)
- Object (12)
-
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ TYPE (12)
モジュール
- Enumerable (96)
- Forwardable (24)
キーワード
- ! (12)
- != (12)
-
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) -
def
_ delegator (12) -
def
_ instance _ delegator (12) -
default
_ event _ sources (12) - handler= (12)
- max (48)
- min (48)
- new (12)
-
rexml
/ parsers / streamparser (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 9 feature (12) -
yaml
_ tag (12)
検索結果
先頭5件
-
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='<'/>
&& <!-- 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("...