クラス
- CSV (22)
- Data (4)
-
RubyVM
:: InstructionSequence (22) - String (28)
キーワード
- define (4)
- disasm (11)
- disassemble (11)
- instance (22)
- new (28)
検索結果
先頭5件
- String
. new(string = "" , encoding: string . encoding , capacity: string . bytesize) -> String - String
. new(string = "" , encoding: string . encoding , capacity: 127) -> String - String
. new(string = "" , encoding: string . encoding , capacity: 63) -> String - String
. new(string = "" , encoding: string . encoding) -> String - String
. new(string = "") -> String
-
String
. new(string = "" , encoding: string . encoding , capacity: string . bytesize) -> String (21492.0) -
string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。
...
string と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。
@param string 文字列
@param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト......で指定します(変換は行われま
せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@param capa......合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@return 引数 string と同じ内容の文字列オブジェクト
//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)... -
String
. new(string = "" , encoding: string . encoding , capacity: 127) -> String (21392.0) -
string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。
...
string と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。
@param string 文字列
@param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト......で指定します(変換は行われま
せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@param capa......合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@return 引数 string と同じ内容の文字列オブジェクト
//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)... -
String
. new(string = "" , encoding: string . encoding , capacity: 63) -> String (21392.0) -
string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。
...
string と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。
@param string 文字列
@param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト......で指定します(変換は行われま
せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@param capa......合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@return 引数 string と同じ内容の文字列オブジェクト
//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)... -
String
. new(string = "" , encoding: string . encoding) -> String (21370.0) -
string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。
...
string と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。
@param string 文字列
@param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト......せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@return 引数 string と同じ内容の文字列オブジ......ext = "hoge".encode("EUC-JP")
no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with_encoding.encoding == Encoding::UTF_8 # => tru... -
String
. new(string = "") -> String (21292.0) -
string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。
...
string と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。
@param string 文字列
@return 引数 string と同じ内容の文字列オブジェクト
//emlist[例][ruby]{
text = "hoge".encode("EUC-J......P")
no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
//}......
string と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。
@param string 文字列
@param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト......せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@return 引数 string と同じ内容の文字列オブジ......ext = "hoge".encode("EUC-JP")
no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with_encoding.encoding == Encoding::UTF_8 # => tru......で指定します(変換は行われま
せん)。省略した場合は引数 string のエンコーディングと同
じになります(ただし、string が指定されていなかった場合は
Encoding::ASCII_8BITになります)。
@param capa......合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@return 引数 string と同じ内容の文字列オブジェクト
//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)... -
RubyVM
:: InstructionSequence . disasm(body) -> String (121.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
...た場合
# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)
出力:
== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0......:hello))
出力:
== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace 8 ( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello,... -
RubyVM
:: InstructionSequence . disassemble(body) -> String (121.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
...た場合
# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)
出力:
== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0......:hello))
出力:
== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace 8 ( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello,... -
Data
. define(*args) -> Class (25.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end
def fetch(url)
fetch......引数。Symbol または String を指定します。
@return Data のサブクラスを返します。
@raise TypeError 引数に Symbol, String (String に暗黙の型変換が行われるオブジェクトを含む) 以外を指定した場合に発生します。
=== ブロックを指定し... -
Data
. define(*args) {|subclass| block } -> Class (25.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end
def fetch(url)
fetch......引数。Symbol または String を指定します。
@return Data のサブクラスを返します。
@raise TypeError 引数に Symbol, String (String に暗黙の型変換が行われるオブジェクトを含む) 以外を指定した場合に発生します。
=== ブロックを指定し... -
CSV
. instance(data = $ stdout , options = Hash . new) -> CSV (13.0) -
このメソッドは CSV.new のように CSV のインスタンスを返します。 しかし、返される値は Object#object_id と与えられたオプションを キーとしてキャッシュされます。
...ロックが与えられた場合、生成されたインスタンスをブロックに渡して評価した
結果を返します。
@param data String か IO のインスタンスを指定します。
@param options CSV.new のオプションと同じオプションを指定できます。
//em......aro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
csv = CSV.instance(text, options)
csv2 = CSV.instance(text, options)
csv.object_id == csv2.object_id # => true
print csv.read
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21... -
CSV
. instance(data = $ stdout , options = Hash . new) {|csv| . . . } -> object (13.0) -
このメソッドは CSV.new のように CSV のインスタンスを返します。 しかし、返される値は Object#object_id と与えられたオプションを キーとしてキャッシュされます。
...ロックが与えられた場合、生成されたインスタンスをブロックに渡して評価した
結果を返します。
@param data String か IO のインスタンスを指定します。
@param options CSV.new のオプションと同じオプションを指定できます。
//em......aro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
csv = CSV.instance(text, options)
csv2 = CSV.instance(text, options)
csv.object_id == csv2.object_id # => true
print csv.read
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21...