[#50422] [ANN] Rroonga - 6.0.9 - 高速全文検索ライブラリー — Masafumi Yokoyama <yokoyama@...>
横山です。
4 messages
2016/10/11
[#50424] [質問] Blowfishの鍵について — 松永 肇一 <ma2@...>
松永と申します。
5 messages
2016/10/12
[#50431] bundle exec での日本語を含む引数の文字化け workaround (Windows環境) — Toshihiko Ichida <dogatana@...>
市田です。
4 messages
2016/10/16
[ruby-list:50442] Re: [質問] インスタンスメッソド hookについて
From:
dezawa <dezawa@...>
Date:
2016-10-25 13:09:01 UTC
List:
ruby-list #50442
市田さんの言われる
> 共通の処理をくくりだすというのであれば、共通部分を別メソッドとして定義
> して、対象となるメソッドの先頭で呼び出すというのはどうでしょうか。
が良いのでは
class WebAPI
attr_reader :is_in_nw
def initialize(ip,is_in_nw=false)
@ip = ip
@is_in_nw = is_in_nw
end
def check_and_go(&block)
if !is_in_nw then
puts "TV(#{@ip}) is not in Network"
return nil
end
yield
end
def Register(code)
check_and_go{
puts "Register(code)"
}
end
end
code=12
webapi =WebAPI.new("ip",true)
webapi.Register(code)
webapi =WebAPI.new("ip",false)
webapi.Register(code)