るりまサーチ

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

別のキーワード

  1. string []=
  2. string slice
  3. string []
  4. string slice!
  5. string gsub!

キーワード

検索結果

<< 1 2 > >>

String#oct -> Integer (27204.0)

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

...例][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
//}

...
...list[例][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 (9043.0)

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

...to_i(0) # => 16
//}

@
param base 進数を指定する整数。0 か、2〜36 の整数。
@
return 整数

このメソッドの逆に数値を文字列に変換するには、
Kernel.#sprintf, String#%, Integer#to_s
を使用します。

String
#hex, String#oct, String#to_f,
Kernel.#Inte...

String#hex -> Integer (9037.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...# => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

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

このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer#to_s
などを使ってください。...

String#to_f -> Float (9037.0)

文字列を 10 進数表現と解釈して、浮動小数点数 Float に変換します。

...# => Infinity
# warning: Float 10101010101010101010... out of range
//}

なお、このメソッドとは逆に、数値を文字列に変換するには
Kernel.#sprintf, String#%, Integer#to_s
を使用します。

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

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

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

...いない、のいずれかの場合は nil を返します。

@
param element 要素名(文字列)
@
param attribute 属性名(文字列)

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

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>...
...title CDATA #REQUIRED
publisher CDATA "foobar 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#entity(name) -> String | nil (3108.0)

name という実体参照名を持つ実体を文字列で返します。

...つ実体が存在しない場合には nil を返します。

@
param name 実体参照名(文字列)

//emlist[][ruby]{
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE foo [
<!ENTITY bar "barbarbarbar">
]>
EOS
p doctype.entity("bar") # => "barbarbar"
p doctype.entity("foo") # => nil
//}...

Rake::RDocTask#quote(str) -> String (3108.0)

Rake::RDocTask#external が真の場合は与えられた文字列をクオートします。

...Rake::RDocTask#external が真の場合は与えられた文字列をクオートします。

@
param str クオートする文字列を指定します。...

WEBrick::HTTPResponse#[](field) -> String (114.0)

レスポンスのヘッダの該当する内容を文字列で返します。

...レスポンスのヘッダの該当する内容を文字列で返します。

@
param field ヘッダ名を文字列で指定します。大文字と小文字を区別しません。

p res['date'] #=> "Sat, 27 Oct 2007 08:53:03 GMT"...

WEBrick::HTTPResponse#content_length -> Integer | nil (19.0)

Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。

...Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。

: body が String オブジェクトである場合
content_length の値が nil のとき Content-Length ヘッダには
body のサイズが使われます。nil でないとき body の実...
...いけない場合に当てはまる時には
content_length の値は無視され Content-Length ヘッダはレスポンスに含まれません。

@
param len ヘッダの値を整数で指定します。nil を指定することは出来ません。

require 'webrick'
include WEBrick
res =...
...HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
print res.to_s

#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 12:04:32 GMT
Server:
Content-Length: 2

ho...
<< 1 2 > >>