るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

キーワード

検索結果

Encoding::Converter#finish -> String (26116.0)

変換処理を終了し、結果文字列の末尾を返します。 変換元の文字列の末尾がバイト列の途中で終わっていた場合、保持しているバイト列全てを返します。

...::InvalidByteSequenceError 変換元のエンコーディングにお
いて不正なバイト列があった場合に発生します。

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
p ec.convert("\u3042") #=> "\e$B$\""
p ec.finish #=> "\e(B"
//}...

Encoding::Converter#convert(source_string) -> String (8055.0)

与えられた文字列を変換して、変換できた結果を返します。 引数の末尾の文字がバイト列の途中で終わっている場合、そのバイト列は変換器内に取り置かれます。 変換を終了させるには Encoding::Converter#finish を呼びます。

...中で終わっている場合、そのバイト列は変換器内に取り置かれます。
変換を終了させるには Encoding::Converter#finish を呼びます。

Encoding::Converter を用いると、文字列の一部または全部を渡して変換を行うことができます。よっ...
...g::Converter.new("utf-8", "euc-jp")
puts ec.convert("\u3042").dump #=> "\xA4\xA2"
puts ec.finish.dump #=> ""

ec = Encoding::Converter.new("euc-jp", "utf-8")
puts ec.convert("\xA4").dump #=> ""
puts ec.convert("\xA2").dump #=> "\xE3\x81\x82"
puts ec.finish.dump...
...coding::Converter.new("utf-8", "iso-2022-jp")
puts ec.convert("\xE3").dump #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x81").dump #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x82").dump #=> "\e$B$\"".force_encoding("ISO-2022-JP")
puts ec.finish.dump...

Object#respond_to?(name, include_all = false) -> bool (8051.0)

オブジェクトがメソッド name を持つとき真を返します。

...g"
end
end
list = [F.new,D.new]

list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour

list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hello, true)")}
#=> Bonjour
# Guten Tag

module Template
def main
start
template_method
finish

end

def start...
...mentedError.new
end

def finish
puts "finish"
end
end

class ImplTemplateMethod
include Template
def template_method
"implement template_method"
end
end

class NotImplTemplateMethod
include Template

# not implement template_method
end

puts ImplTemplateMethod.new.respond_to?...
...emplate_method) # => true
# NotImplementedError が発生しているが、Rubyによる実装部のため true を返す
puts NotImplTemplateMethod.new.respond_to?(:template_method) # => true
# GNU/Linux で実行。C言語による実装部のため false を返す
puts File.respond_to?(:lchmod)...

Encoding::InvalidByteSequenceError#incomplete_input? -> bool (8015.0)

エラー発生時に入力文字列が不足している場合に真を返します。

...ing::Converter.new("EUC-JP", "ISO-8859-1")

begin
ec.convert("abc\xA1z")
rescue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "z" on EUC-JP>
p $!.incomplete_input? #=> false
end

begin
ec.convert("abc\xA1")
ec.finish
rescue Encodi...