るりまサーチ

最速Rubyリファレンスマニュアル検索!
194件ヒット [1-100件を表示] (0.051秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 > >>

String#end_with?(*strs) -> bool (6145.0)

self の末尾が strs のいずれかであるとき true を返します。

...ずれかであるとき true を返します。

@
param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@
see String#start_with?...
...ます。

@
param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@
see String#start_with?
@
see String#delete_suffix, String#delete_...

String#append_as_bytes(*objects) -> self (6120.0)

引数で与えたオブジェクトをバイト列として、self に破壊的に連結します。

...を越える場合は、最下位のバイトのみを使用します。

//emlist[例][ruby]{
s = "あ".b # => "\xE3\x81\x82"
s.encoding # => #<Encoding:BINARY (ASCII-8BIT)>
s.append_as_bytes("い") # => "\xE3\x81\x82\xE3\x81\x84"

# s << "い" では連結できな...
...
s << "い" # => "incompatible character encodings: BINARY (ASCII-8BIT) and UTF-8 (Encoding::CompatibilityError)
//}

//emlist[引数で整数を渡す例][ruby]{
t = ""
t.append_as_bytes(0x61) # => "a"
t.append_as_bytes(0x3062) # => "ab"
//}

@
see String#<<, String#concat...

String#prepend(*arguments) -> String (6116.0)

複数の文字列を先頭に破壊的に追加します。

...複数の文字列を先頭に破壊的に追加します。

@
param arguments 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "!!!"
a.prepend # => "!!!"
a # => "!!!"

a = "!!!"
a.prepend "hello ", "world" # => "hello world!!!"
a # => "hello...

String#prepend(other_str) -> String (6116.0)

文字列 other_str を先頭に破壊的に追加します。

...文字列 other_str を先頭に破壊的に追加します。

@
param other_str 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "world"
a.prepend("hello ") # => "hello world"
a # => "hello world"
//}...

String#unpack(template) -> Array (674.0)

Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。

...アンパックし、
それらの要素を含む配列を返します。

@
param template pack テンプレート文字列
@
return オブジェクトの配列


以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文...
...、整数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}

: エンディアン依存、整数サイズ依存 (C の構造体などに...
...に適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

=== 各テンプレート文字の説明

説明中、Array#pack と String#unpack で違いのあるものは...
...ックし、
それらの要素を含む配列を返します。

@
param template pack テンプレート文字列
@
return オブジェクトの配列


以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレ...

絞り込み条件を変える

String#%(args) -> String (224.0)

printf と同じ規則に従って args をフォーマットします。

...す。
それ以外の場合は Kernel.#sprintf(self, args) と同じです。

@
param args フォーマットする値、もしくはその配列
@
return フォーマットされた文字列

//emlist[例][ruby]{
p "i = %d" % 10 # => "i = 10"
p "i = %x" % 10 # => "i = a"
p "...
...= 0xa"
p "i = %#o" % 10 # => "i = 012"

p "%d" % 10 # => "10"
p "%d,%o" % [10, 10] # => "10,12"
//}

=== sprintf フォーマット

Ruby
の sprintf フォーマットは基本的に C 言語の sprintf(3)
のものと同じです。ただし、short や long などの C 特有の...
..., %B)が存在すること、sprintf のすべての方言をサ
ポートしていないこと(%': 3桁区切り)などの違いがあります。

Ruby
には整数の大きさに上限がないので、%b, %B, %o, %x, %X
に負の数を与えると (左側に無限に1が続くとみなせるの...

String#delete_suffix!(suffix) -> self | nil (56.0)

self の末尾から破壊的に suffix を削除します。

...

@
param suffix 末尾から削除する文字列を指定します。

@
return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_suffix!("llo") # => "he"
"hello".delete_suffix!("hel") # => nil
//}

@
see String#chomp!
@
see String#chop!
@
see String#d...
...elete_prefix!
@
see String#delete_suffix
@
see String#end_with?...

String#delete_suffix(suffix) -> String (56.0)

文字列の末尾から suffix を削除した文字列のコピーを返します。

...

@
param suffix 末尾から削除する文字列を指定します。

@
return 文字列の末尾から suffix を削除した文字列のコピー

//emlist[][ruby]{
"hello".delete_suffix("llo") # => "he"
"hello".delete_suffix("hel") # => "hello"
//}

@
see String#chomp
@
see String#chop
@
see String...
...#delete_prefix
@
see String#delete_suffix!
@
see String#end_with?...

String#==(other) -> bool (38.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。

@
param...
...
@
return true か false

//emlist[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end


p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end


p "string".eql?(stringlike) #=> false
p "string" == stringl...
...ike #=> true
//}

@
see String#eql?...

String#===(other) -> bool (38.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。

@
param...
...
@
return true か false

//emlist[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end


p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end


p "string".eql?(stringlike) #=> false
p "string" == stringl...
...ike #=> true
//}

@
see String#eql?...

絞り込み条件を変える

String#crypt(salt) -> String (32.0)

self と salt から暗号化された文字列を生成して返します。 salt には英数字、ドット (「.」)、スラッシュ (「/」) から構成される、 2 バイト以上の文字列を指定します。

...くランダムな文字列を選ぶべきです。
他にも 29297 などがあります。

注意:

* Ruby 2.6 から非推奨になったため、引き続き必要な場合は
string
-crypt gem の使用を検討してください。
* crypt の処理は crypt(3) の実装に依存して...
...初の 2 バイトだけが使用されます。

@
param salt 文字列を暗号化するための鍵となる文字列。
英数字・「.」・「/」のいずれかで構成される 2 バイト以上の文字列

//emlist[例][ruby]{
# パスワードの暗号化
salt = [rand(64)...
...,rand(64)].pack("C*").tr("\x00-\x3f","A-Za-z0-9./")
passwd.crypt(salt)

# UNIX のログイン認証
require 'etc'

def valid_login?(user, password)
ent = Etc.getpwnam(user)
password.crypt(ent.passwd) == ent.passwd
end


p valid_login?("taro", "password") # => 真偽値が得られる
//}...
<< 1 2 > >>