るりまサーチ

最速Rubyリファレンスマニュアル検索!
283件ヒット [101-200件を表示] (0.082秒)
トップページ > クエリ:ruby[x] > クエリ:Ruby[x] > クエリ:string[x] > クエリ:String[x] > クエリ:instance[x] > クエリ:class[x]

別のキーワード

  1. string []=
  2. string slice!
  3. string slice
  4. string []
  5. string gsub!

検索結果

<< < 1 2 3 > >>

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (6282.0)

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or  plus minus ast slash hat sq  period comma langl rangl eq tilde  dollar at under lbrarbra  lbra2rbra2 lbra3rbra3 dq colon ac  backslash semicolon

...Rubyで使われる記号の意味(正規表現の複雑な記号は除く)
ex q num per and or 
plus minus ast slash hat sq 
period comma langl rangl eq tilde 
dollar at under lbrarbra 
lbra2rbra2 lbra3rbra3 dq colon ac 
backslash semicol...
...: /xxx/ !~ yyy

正規表現のメソッド =~ の否定。マッチが失敗したらtrueを返します。


===[a:q] ?

: ?a

d:spec/literal#string。長さ 1 の文字列。

: def xx?

この場合の「?」はメソッド名の一部分です。
慣用的に、真偽値を返すタイプ...
...#! ruby -Ks

shebang。d:spec/rubycmd#shebangを参照。

: # coding: utf-8

マジックコメント。d:spec/m17n#magic_comment を参照。

: "a is #{a}"

d:spec/literal#exp
//emlist{
a = 10
p "a is #{a}" #=> "a is 10"
//}

: Range#each

説明文の中でのみ使われます。Ruby...

Module#instance_method(name) -> UnboundMethod (6185.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...@param name メソッド名を Symbol または String で指定します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#public_instance_method, Object#method

//emlist[例][ruby]{
class
Interpreter
def do_a() print "there, "; end...
...end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string
.each_char {|b| Dispatcher[b].bind(self).call }
end
end

interpr...

Module#remove_class_variable(name) -> object (6149.0)

引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。

...引数で指定したクラス変数を取り除き、そのクラス変数に設定さ
れていた値を返します。

@param name String または Symbol を指定します。

@return 引数で指定されたクラス変数に設定されていた値を返します。

@raise NameError 引数...
...ールやクラスに定義されていない場合に発生します。

//emlist[例][ruby]{
class
Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}

@see Module#remove_const, Object#remove_instance_variable...

1.6.8から1.8.0への変更点(まとめ) (4494.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...動作はなくなりました)

$defout や $deferr に代入を行うと警告がでます。
(注:1.6 に $deferr はありません)
((<ruby-dev:20961>))

$stdin にオブジェクトを代入すると標準入力からの入力メソッド(gets 等)
はそのオブジェクトにメ...
...ます。

: ruby interpreter [ruby] [change]

クラスの特異クラスの特異クラスは特異クラス自身であると定義されました
((<ruby-bugs-ja:313>))。なんだかよくわかりません(^^;

class
<< Object
p [self.id, self]
class
<< self...
...self]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09-05) [i586-linux]
[537771634, #<Class:Object>]
[537771634, #<Class:Object>]

さらに、オブジェク...

クラス/メソッドの定義 (792.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined

===[a:class] クラス定義

//emlist[例][ruby]{
class
Foo < S...
...ec/control#begin参照。

クラス定義は、識別子で指定した定数へのクラスの代入になります
(Ruby では、クラスもオブジェクトの一つで Classクラスの
インスタンスです)。

クラスが既に定義されているとき、さらに同じクラス名...
.../emlist[][ruby]{
class
Foo < Array
def foo
end
end

# 定義を追加(スーパークラス Array を明示的に指定しても同じ)
class
Foo
def bar
end
end

# 間違ったスーパークラスを指定するとエラー
class
Foo < String
end
# => superclass mismatch for class Foo (Typ...

絞り込み条件を変える

Marshal フォーマット (726.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...ります。

//emlist[][ruby]{
p Marshal.dump(nil).unpack1("x2 a*") # => "0"
p Marshal.dump(true).unpack1("x2 a*") # => "T"
p Marshal.dump(false).unpack1("x2 a*") # => "F"
//}

Ruby
2.1 以前では、インスタンス変数を設定しても dump されません。
Ruby
2.2 以降は freeze...
...いう数値(1 byte)を格納します。5 を足したり引いたりするのは下記の
形式 2 との区別のためです。

//emlist[例][ruby]{
p Marshal.dump(-1).unpack1("x2 a*") # => "i\xFA"
p Marshal.dump(0).unpack1("x2 a*") # => "i\x00"
p Marshal.dump(1).unpack1("x2 a*") # => "i\x06"...
...bytes
//}

len の値は -4 〜 -1, 1 〜 4 で。符号と後続のデータが n1 〜 n_len
まであることを示します。

//emlist[][ruby]{
def foo(len, n1, n2 = 0, n3 = 0, n4 = 0)
case len
when -3; n4 = 255
when -2; n3 = n4 = 255
when -1; n2 = n3 = n4 =...

パターンマッチ (510.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...にする機能です。(『束縛』は、パターンマッチの輸入元である関数型言語の用語で、Ruby では代入と読み替えても問題ありません)

Ruby
でのパターンマッチは case/in 式を用いて実装されています。

case <expression>
in <pattern1>...
...PatternError が発生します。

そのため、条件付きのマッチや展開に case 式が使われることがあります。

//emlist[][ruby]{
config = {db: {user: 'admin', password: 'abc123'}}

case config
in db: {user:} # ネストしてハッシュにマッチして、その値を変...
...照してください。

===[a:patterns] パターン

パターンで利用できるものには次のものがあります。

* すべてのRubyオブジェクト (when と同じように、『===』演算子でマッチする) (「Value パターン」)
* Array パターン: 『[<subpattern...

irb (460.0)

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

...irb は Interactive Ruby の略です。
irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

=== irb の使い方

Ruby
さえ知っていれば irb を使うのは簡単です。
irb コマンドを実行すると、以下のようなプロン...
...プトが表れます。

$ irb
irb(main):001:0>

あとは Ruby の式を入力するだけで、その式が実行され、結果が表示されます。

irb(main):001:0> 1+2
3
irb(main):002:0> class Foo
irb(main):003:1> def foo
irb(main):004:2> print 1
irb(main):005:2> en...
...$DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library ruby -r と同じ
-I ruby -I と同じ
-U ruby -U と同じ
-E enc ruby -E と同じ
--verbose...

UnboundMethod#arity -> Integer (126.0)

メソッドが受け付ける引数の数を返します。

...][ruby]{
class
C
def one; end
def two(a); end
def three(*a); end
def four(a, b); end
def five(a, b, *c); end
def six(a, b, *c, &d); end
end

p C.instance_method(:one).arity #=> 0
p C.instance_method(:two).arity #=> 1
p C.instance_method(:three).arity #=> -1
p C.instance_...
...hod(:four).arity #=> 2
p C.instance_method(:five).arity #=> -3
p C.instance_method(:six).arity #=> -3


String
.instance_method(:size).arity #=> 0
String
.instance_method(:replace).arity #=> 1
String
.instance_method(:squeeze).arity #=> -1
String
.instance_method(:count).arity #=>...

Object#===(other) -> bool (120.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...[][ruby]{
age = 12
# (0..2).===(12), (3..6).===(12), ... が実行される
result =
case age
when 0 .. 2
"baby"
when 3 .. 6
"little child"
when 7 .. 12
"child"
when 13 .. 18
"youth"
else
"adult"
end

puts result #=> "child"

def check arg
case arg
when /ruby(?!...
...ls)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end

puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's world>
//}

@see Object#==...

絞り込み条件を変える

<< < 1 2 3 > >>