るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

String#oct -> Integer (48282.0)

文字列を 8 進文字列であると解釈して、整数に変換します。

...emlist[例][ruby]{
p "10".oct # => 8
p "010".oct # => 8
p "8".oct # => 0
//}

oct
は文字列の接頭辞 ("0", "0b", "0B", "0x", "0X") に応じて
8 進以外の変換も行います。

//emlist[例][ruby]{
p "0b10".oct # => 2
p "10".oct # => 8
p "010".oct # => 8
p "0x10".oct # => 16
/...
...//emlist[例][ruby]{
p "-010".oct # => -8
p "-0x10".oct # => -16
p "-0b10".oct # => -2

p "1_0_1x".oct # => 65
//}

@see String#hex, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float

逆に、数値を文字列に変換するにはKernel.#sprintf,
String
#%, Integer#to_s...

String#to_i(base = 10) -> Integer (30221.0)

文字列を 10 進数表現された整数であると解釈して、整数に変換します。

...ruby]{
p " 10".to_i # => 10
p "+10".to_i # => 10
p "-10".to_i # => -10

p "010".to_i # => 10
p "-010".to_i # => -10
//}

整数とみなせない文字があればそこまでを変換対象とします。
変換対象が空文字列であれば 0 を返します。

//emlist[例][ruby...
...現へ変換できます。
それぞれ Ruby の整数リテラルで使用可能なプリフィクスは無視されます。
また、base に 0 を指定するとプリフィクスから基数を判断します。
認識できるプリフィクスは、
0b (2 進数)、0 (8 進数)、0o (8 進...
...合は
例外 ArgumentError が発生します。

//emlist[例][ruby]{
p "01".to_i(2) # => 1
p "0b1".to_i(2) # => 1

p "07".to_i(8) # => 7
p "0o7".to_i(8) # => 7

p "1f".to_i(16) # => 31
p "0x1f".to_i(16) # => 31

p "0b10".to_i(0) # => 2
p "0o10".to_i(0) # => 8
p "010".to_i(0) # =>...

REXML::DocType#attribute_of(element, attribute) -> String | nil (9415.0)

DTD 内の属性リスト宣言で、 element という名前の要素の attribute という 名前の属性のデフォルト値を返します。

...宣言で、 element という名前の要素の attribute という
名前の属性のデフォルト値を返します。

elementという名前の要素の属性値は宣言されていない、
elementという名前の要素にはattributeという名前の属性が宣言されていない、...
...bute 属性名(文字列)

//emlist[][ruby]{
require 'rexml/document'

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book
author CDATA #REQUIRED
title CDATA #REQUIRED
publisher CDATA "foob...
...ar publisher">
]>
EOS

p doctype.attribute_of("book", "publisher") # => "foobar publisher"
p doctype.attribute_of("bar", "foo") # => nil
p doctype.attribute_of("book", "baz") # => nil
p doctype.attribute_of("book", "title") # => nil
//}...

REXML::DocType#public -> String | nil (9315.0)

DTD の公開識別子を返します。

...mlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
EOS
doctype.system # => "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype.public # =...
...> "-//W3C//DTD XHTML 1.0 Strict//EN"

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE root SYSTEM "foobar">
EOS
doctype.system # => "foobar"
doctype.public # => nil
//}...