クラス
-
ARGF
. class (12) - Data (3)
- Hash (34)
- Object (30)
- OpenStruct (14)
- String (267)
- Symbol (9)
- WIN32OLE (12)
モジュール
- Enumerable (12)
- FileUtils (12)
キーワード
- capitalize (12)
- capitalize! (12)
- chunk (12)
- downcase (12)
- downcase! (12)
- eql? (3)
-
fetch
_ values (20) - gsub (48)
- gsub! (48)
-
inplace
_ mode (12) -
ole
_ func _ methods (12) - ruby (12)
- sub (36)
- sub! (36)
- swapcase (12)
- swapcase! (12)
- then (14)
-
to
_ h (28) - upcase! (12)
- with (3)
-
yield
_ self (16)
検索結果
先頭5件
-
String
# upcase -> String (21214.0) -
'a' から 'z' までのアルファベット小文字を大文字に変換した文字列を作成して返します。
...字として認識する」だけであって、
いわゆる全角アルファベットの大文字小文字までは変換しません。
//emlist[例][ruby]{
p "stRIng? STring.".upcase # => "STRING? STRING."
//}
@see String#upcase!, String#downcase,
String#swapcase, String#capitalize... -
String
# upcase(*options) -> String (21214.0) -
全ての小文字を対応する大文字に置き換えた文字列を返します。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。
...のエンコーディングに依存します。
@param options オプションの詳細は String#downcase を参照してください。
//emlist[例][ruby]{
p "stRIng? STring.".upcase # => "STRING? STRING."
//}
@see String#upcase!, String#downcase,
String#swapcase, String#capitalize... -
Symbol
# upcase(*options) -> Symbol (18220.0) -
小文字を大文字に変換したシンボルを返します。
...小文字を大文字に変換したシンボルを返します。
(self.to_s.upcase.intern と同じです。)
:foo.upcase #=> :FOO
@see String#upcase... -
String
# upcase!(*options) -> self | nil (9214.0) -
全ての小文字を対応する大文字に破壊的に置き換えます。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。
...ディングに依存します。
@param options オプションの詳細は String#downcase を参照してください。
//emlist[例][ruby]{
buf = "stRIng? STring."
buf.upcase!
p buf # => "STRING? STRING."
//}
@see String#upcase, String#downcase!,
String#swapcase!, String#capitalize!... -
String
# upcase! -> self | nil (9114.0) -
ASCII 文字列の範囲内で 'a' から 'z' までの アルファベット小文字を全て大文字にします。 このメソッドは self を破壊的に変更して返しますが、 置換が起こらなかった場合は nil を返します。
...識する」だけであって、
いわゆる全角アルファベットの大文字小文字までは変換しません。
//emlist[例][ruby]{
buf = "stRIng? STring."
buf.upcase!
p buf # => "STRING? STRING."
//}
@see String#upcase, String#downcase!,
String#swapcase!, String#capitalize!... -
WIN32OLE
# ole _ func _ methods -> [WIN32OLE _ METHOD] (6207.0) -
オブジェクトのファンクション情報をWIN32OLE_METHODの配列として返し ます。
...32OLE_METHODの配列として返し
ます。
ole_func_methodsメソッドは、OLEオートメーションサーバのメソッドのうちファ
ンクション(何らかの機能的な操作)に属するものをWIN32OLE_METHODの
配列として返します。
@return WIN32OLE_METHODの......untimeError オートメーションサーバの呼び出しに失敗しました。
型情報ライブラリ(TypeLib)が提供されていない場合などに発生します。
excel = WIN32OLE.new('Excel.Application')
excel.visible = true
excel.ole_func_metho......ds.each do |fun|
if fun.name.upcase == 'QUIT'
excel._invoke(fun.dispid, [], [])
break
end
end
@see WIN32OLE#ole_methods, WIN32OLE#ole_get_methods,
WIN32OLE#ole_put_methods... -
Data
# with(**kwargs) -> Data (6107.0) -
self をコピーしたオブジェクトを返します。
...gumentError 存在しないメンバを指定した場合に発生します。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5) # => #<data Dog name="Fred", age=5>
dog2 = dog1.with(age: 6) # => #<data Dog name="Fred", age=6>
p dog1 # => #<data Dog......"Fred", age=5>
dog3 = dog1.with(type: "Terrier") # => ArgumentError (unknown keyword: :type)
# メンバのオブジェクトはコピーされず、同じオブジェクトを参照する。
dog1.name.upcase!
p dog1 # => #<data Dog name="FRED", age=5>
p dog2 # => #<data Dog name="FRED", age=6>
//......}
[注意] 本メソッドの記述は Data のサブクラスのインスタンスに対して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。... -
Hash
# fetch _ values(key , . . . ) -> [object] (6107.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...ます。
//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "B......IRD"]
//}
@see Hash#values_at, Hash#fetch... -
Hash
# fetch _ values(key , . . . ) { |key| . . . } -> [object] (6107.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...ます。
//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "B......IRD"]
//}
@see Hash#values_at, Hash#fetch... -
Hash
# to _ h -> self | Hash (6107.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...h オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.class # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定す......ると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ h {|key , value| block } -> Hash (6107.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...h オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.class # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定す......ると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}
@see Enumerable#map... -
Object
# then -> Enumerator (6107.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...果を返します。
//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパ......quire 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件......にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# then {|x| . . . } -> object (6107.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...果を返します。
//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパ......quire 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件......にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
OpenStruct
# to _ h -> { Symbol => object } (6107.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...。
//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBE...