17件ヒット
[1-17件を表示]
(0.114秒)
ライブラリ
- cmath (6)
- forwardable (11)
キーワード
- CMath (6)
- SingleForwardable (11)
検索結果
先頭2件
-
SingleForwardable (6007.0)
-
オブジェクトに対し、メソッドの委譲機能を定義するモジュールです。
...require 'forwardable'
g = Goo.new
g.extend SingleForwardable
g.def_delegator("@out", :puts)
g.puts ...
また、SingleForwardable はクラスやモジュールに対して以下のようにする事もできます。
require 'forwardable'
class Implementation
def self.service......puts "serviced!"
end
end
module Facade
extend SingleForwardable
def_delegator :Implementation, :service
end
Facade.service # => serviced!
もし Forwardable と SingleForwardable の両方を使いたい場合、
def_instance_delegator と def_single_delegator メソッ... -
CMath (19.0)
-
複素数演算をサポートするモジュールです。
...、「メソッド名!」の形式で呼び出します。
//emlist[例][ruby]{
require "cmath"
# 複素数の範囲の立方根(の主値)= exp(1/3 πi)
CMath.cbrt(-1) # => (0.5000000000000001+0.8660254037844386i)
# 実数の範囲の立方根
Math.cbrt(-1) # => -1.0
include CMath
# レシ......ーバー無しで使える
cbrt(-1) # => (0.5000000000000001+0.8660254037844386i)
# cbrt! は Math.cbrt のエイリアス
cbrt!(-1) # => -1.0
//}...