ライブラリ
- ビルトイン (11)
- observer (11)
- openssl (22)
-
rubygems
/ requirement (11)
クラス
- BasicObject (11)
-
Gem
:: Requirement (11)
キーワード
- OCSP (11)
- OPS (11)
- Observable (11)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- SSLSocket (11)
-
rb
_ ary _ push (11) -
rexml
/ parsers / sax2parser (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) - tsort (11)
- 演算子式 (11)
検索結果
先頭5件
-
ruby 1
. 9 feature (23480.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
...* [regexp]: 正規表現の機能拡張
* [marshal]: Marshal ファイルのフォーマット変更
* レベル
* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど(互換性のある変更) (only backward-......: UNIXserver
削除
=== 2006-06-11
: __callee__ [new]
: __method__ [new]
((<URL:http://www.dm4lab.to/~usa/ruby/d/200606a.html#id20060610_P1_7>))
: Symbol#to_proc
=== 2006-06-10
* 新機能
: BasicObject が導入されました [new]
: local という visibility および Module#loca......ックを渡せるようになり、ブロックが真になる要素の個数を返すように
なりました。
[1,2,3].nitems{|i| i % 2 != 0} #=> 2
((<ruby-talk:134083>))
=== 2005-06-02
: proc [ruby][parser][experimental]
以前のローカル変数に括弧を付けると call... -
ruby 1
. 8 . 4 feature (23174.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...ruby]: ruby インタプリタの変更
# * [api]: 拡張ライブラリ API
# * [lib]: ライブラリ
* レベル
* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど
* 互換性のある変更
* on......* ((<ruby 1.8.4 feature/Hash [bug]>))
* ((<ruby 1.8.4 feature/test [bug]>))
* ((<ruby 1.8.4 feature/File.identical? [new]>))
* ((<ruby 1.8.4 feature/FileTest.identical? [new]>))
* ((<ruby 1.8.4 feature/File.split [change]>))
* ((<ruby 1.8.4 feature/File.basename [change]>))
* ((<ruby 1.8......* ruby.h (Qfalse, Qtrue, Qnil, Qundef): make sure these immediate
# values have VALUE type. there is an environment where sizeof(VALUE)
# != sizeof(int) like IA64. if 32bit integer (Qtrue) is passed to ANYARGS
# and received by 64bit integer (VALUE), upper bits may have garba... -
BasicObject
# !=(other) -> bool (18124.0) -
オブジェクトが other と等しくないことを判定します。
...否定して返します。
このため、サブクラスで BasicObject#== を再定義しても != とは自動的に整合性が
とれるようになっています。
ただし、 BasicObject#!= 自身や BasicObject#! を再定義した際には、ユーザーの責任で
整合性を保た......sicObject#!
//emlist[例][ruby]{
class NonequalityRecorder < BasicObject
def initialize
@count = 0
end
attr_reader :count
def !=(other)
@count += 1
super
end
end
recorder = NonequalityRecorder.new
recorder != 1
puts 'hoge' if recorder != "str"
p recorder.count #=> 2
//}... -
演算子式 (42.0)
-
演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond
.../ %
+ -
<< >>
&
| ^
> >= < <=
<=> == === != =~ !~
&&
||
.. ...
?:(条件演算子)
=(+=, -= ... )......の記法を利用します。
//emlist{
| ^ & <=> == === =~ > >= < <= << >>
+ - * / % ** ~ +@ -@ [] []= ` ! != !~
//}
これらの演算子式の定義方法についてはd:spec/def#operatorを参照してください。
:再定義できない演算子(......class C
def initialize
@ary = [0,1,2,3,4,5,6,7]
end
def [](i)
@ary[i * 2]
end
def []=( i, v )
@ary[i * 2] = v
end
end
c = C.new
p c[3] # c.[]( 3 ) に変換され、その結果は 6
p c[3] = 1 # c.[]=(3,1) に変換され、その結果は 1
//}
: 属性参照
//eml... -
Gem
:: Requirement :: OPS -> Hash (30.0) -
比較演算子と対応する処理を格納したハッシュです。次の内容と等価です。
...納したハッシュです。次の内容と等価です。
//emlist[][ruby]{
OPS = { #:nodoc:
"=" => lambda {|v, r| v == r },
"!=" => lambda {|v, r| v != r },
">" => lambda {|v, r| v > r },
"<" => lambda {|v, r| v < r },
">=" => lambda {|v, r| v >= r },
"<=" => lambda {|v,......mp },
}.freeze
//}
次のように、Gem::Version どうしを比較します。
//emlist[][ruby]{
p Gem::Requirement::OPS["="].call(Gem::Version.new('3.1'), Gem::Version.new('3.0')) # => false
p Gem::Requirement::OPS["~>"].call(Gem::Version.new('3.1'), Gem::Version.new('3.0')) # => true
//}... -
OpenSSL
:: OCSP (30.0) -
OCSP(Online Certificate Status Protocol)を取り扱うための モジュールです。OCSP は 2560 で定義されています。
...ト)
store # 信頼している証明書ストア
cid = OpenSSL::OCSP::CertificateId.new(subject, issuer)
req = OpenSSL::OCSP::Request.new
req.add_certid(cid)
req.add_nonce
http = Net::HTTP.new('ocsp.example.com', 80)
httpres = http.post("/", req.to_der, 'content-type' => 'applicati......on/ocsp-request')
raise "HTTP error" if !httpres.kind_of?(Net::HTTPOK)
res = OpenSSL::OCSP::Response.new(httpres.body)
puts "Response status: #{res.status_string}"
exit if res.status != OpenSSL::OCSP::RESPONSE_STATUS_SUCCESSFUL
basic_resp = res.basic
raise "nonce error" unless [-1, 1... -
tsort (30.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
...inputs
end
def build(target)
each_strongly_connected_component_from(target) {|ns|
if ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
end
n = ns.first
if Array === n
outputs, i......Errno::ENOENT
outputs_time = nil
end
if outputs_time == nil ||
inputs_time != nil && outputs_time <= inputs_time
sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
block.call
end
end
}
end
def tsort_eac......h_child(node, &block)
@dep[node].each(&block)
end
include TSort
end
def command(arg)
print arg, "\n"
system arg
end
m = Make.new
m.rule(%w[t1]) { command 'date > t1' }
m.rule(%w[t2]) { command 'date > t2' }
m.rule(%w[t3]) { command 'date > t3' }
m.rule(%w[t4], %w[t1 t3]) { command 'cat... -
Observable (24.0)
-
Observer パターンを提供するモジュールです。
...end
def run
last_price = nil
loop do
price = Price.fetch(@symbol)
print "Current price: #{price}\n"
if price != last_price
changed # notify observers
last_price = price
notify_observers(Time.now, price)
en......price > @limit
print "+++ #{time.to_s}: Price above #@limit: #{price}\n"
end
end
end
ticker = Ticker.new("MSFT")
WarnLow.new(ticker, 80)
WarnHigh.new(ticker, 120)
ticker.run
# => Current price: 126
# => +++ 2017-11-02 12:09:36 +0900: Price above 120: 126
# => Curr... -
rexml
/ parsers / sax2parser (24.0) -
SAX2 と同等の API を持つストリーム式の XML パーサ。
...よりは高機能です。
//emlist[][ruby]{
require 'rexml/parsers/sax2parser'
require 'rexml/sax2listener'
parser = REXML::Parsers::SAX2Parser.new(<<XML)
<root n="0">
<a n="1">111</a>
<b n="2">222</b>
<a n="3">333</a>
</root>
XML
elements = []
parser.listen(:start_element){|uri, localnam......missing(name, *args)
p [name, *args]
end
def respond_to_missing?(name, include_private)
name != :call
end
end
parser = REXML::Parsers::SAX2Parser.new(xml)
parser.listen(Listener.new)
parser.parse
# >> [:start_document]
# >> [:xmldecl, "1.0", "UTF-8", nil]
# >> [:progress, 39]
# >> [:c... -
OpenSSL
:: SSL :: SSLSocket (18.0) -
ソケットをラップして SSL での認証と暗号通信を実現するためのクラスです。
...ket'
require 'openssl'
include OpenSSL
soc = TCPSocket.new('www.example.com', 443)
ssl = SSL::SSLSocket.new(soc)
ssl.connect
ssl.post_connection_check('www.example.com')
raise "verification error" if ssl.verify_result != OpenSSL::X509::V_OK
ssl.write('hoge')
print ssl.peer_cert....