るりまサーチ

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

別のキーワード

  1. module attr
  2. module public
  3. module private
  4. module protected
  5. module new

ライブラリ

クラス

モジュール

オブジェクト

キーワード

検索結果

<< < ... 23 24 25 >>

yaml (30.0)

構造化されたデータを表現するフォーマットであるYAML (YAML Ain't Markup Language) を扱うためのライブラリです。

...> true
//}

//emlist[例2: 構造化されたハッシュ][ruby]{
require 'yaml'
require 'date'

str_l = <<~YAML_EOT
Tanaka Taro: {age: 35, birthday: 1970-01-01}
Suzuki Suneo: {
age: 13,
birthday: 1992-12-21
}
YAML_EOT

str_r = {}
str_r["Tanaka Taro"] = {
"age" => 35,
"birthday" =>...
...Date.new(1970, 1, 1)
}
str_r["Suzuki Suneo"] = {
"age" => 13,
"birthday" => Date.new(1992, 12, 21)
}

p str_r == YAML.load(str_l) # => true
//}

//emlist[例3: 構造化されたログ][ruby]{
require 'yaml'
require 'stringio'

strio_r = StringIO.new(<<~YAML_EOT)
---
time: 2008-02-25 17:03...
...OS)
---
!ruby/sym :foo
EOS
# => :foo
//}

yaml では、Ruby 向けに以下のローカルタグを扱えます。

* !ruby/array: Array オブジェクト
* !ruby/class: Class オブジェクト
* !ruby/hash: Hash オブジェクト
* !ruby/module: Module オブジェクト
* !ruby/rege...

NEWS for Ruby 2.4.0 (24.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...a#values_at は named captures をサポートするようになりました 9179

* Module
* Module#refine 引数としてモジュールを許可するようになりました 12534
* Module.used_modules を追加 7418

* Numeric
* Numeric#finite?, Numeric#infinite? を追加 12039...
...字として許可しなくなりました 12791

* csv
* liberal_parsing オプションを追加 11839

* ipaddr
* IPAddr#==, IPAddr#<=> で引数のオブジェクトを IPAddr に変換する処理に失敗しても例外が発生しなくなりました
12799

* irb
* Bi...
...場合、
コンパイルエラーになります。
//emlist{
# 0のクラスはInteger
0.class # => Integer
Fixnum # => Integer
Bignum # => Integer

# 以下の2つは同じ
obj.kind_of?(Fixnum)
obj.kind_of?(Integer)

/* Cレベ...

xmlrpc (24.0)

XML-RPC を扱うためのライブラリです。

...ser)
* xml-scan (XMLScanStreamParser)
* Fastest parser is Expat's XMLStreamParser!

* General
* possible to choose between XMLParser module (Expat wrapper) and REXML/NQXML (pure Ruby) parsers
* Marshalling Ruby objects to Hashs and reconstruct them later from a Hash
* SandStor...
...r (which is now since 1.8
REXMLStreamParser) and a default XML writer. If you want to use a different
XML parser, then you have to call the <i>set_parser</i> method of
XMLRPC::Client instances or instances of subclasses of
XMLRPC::BasicServer or by editing xmlrpc/config.rb.

Client Example:

req...
...is ~350 (!) times faster than
NQXMLTreeParser and still ~18 times as fast as XMLTreeParser.

You can change the XML-writer by calling method <i>set_writer</i>.

=== 参考

* http://www.linux.or.jp/JF/JFdocs/XML-RPC-HOWTO/index.html
* http://www.linux.or.jp/JF/JFdocs/XML-RPC-HOWTO/xmlrpc-howto-r...

制御構造 (18.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...めとする制御構造をクラス設計者が定義する事が出来るものです.

=== 条件分岐
====[a:if] if

//emlist[例][ruby]{
if age >= 12 then
print "adult fee\n"
else
print "child fee\n"
end
gender = if foo.gender == "male" then "male" else "female" end
//}

文法:...
...り強力なパターンマッチ構文を提供しています。

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in a: Integer => m
"matched: #{m}"
else
"not matched"
end
# => "matched: 1"
//}

パターンマッチ構文についてはspec/pattern_matchingで説明しています。

=== 繰り返...
...文が存在しなかったときの値
はnilです。いずれにしてもensure節の値は無視されます。

d:spec/def#class、d:spec/def#module、d:spec/def#method
などの定義文では、それぞれ
begin なしで rescue, ensure 節を定義でき、これにより例外を処理す...

演算子式 (18.0)

演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond

...**
-(単項)
* / %
+ -
<< >>
&
| ^
>
>= < <=
<=> == === != =~ !~
&&
||
.. ...
?...
...ば「&&」は「||」より優先順位が高いので、以下のように
解釈されます。

//emlist[][ruby]{
a && b || c #=> (a && b) || c
a || b && c #=> a || (b && c)
//}

ほとんどの演算子は特別な形式のメソッド呼び出しですが、一部の
ものは言語に組...
...のように変換される
p c.foo # => 5
//}

属性は Module#attr を使って同じように定義できます。

//emlist[例][ruby]{
class C
attr :foo, true
end
c = C.new
c.foo = 5 # c.foo=( 5 ) のように変換される
p c.foo # => 5
//}

====[a:selfassign] 自己代入


/...

絞り込み条件を変える

<< < ... 23 24 25 >>