Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > rinda/rindaライブラリ > Rinda::Templateクラス

class Rinda::Template

クラスの継承リスト: Rinda::Template < Rinda::Tuple < Object < Kernel < BasicObject

要約

タプルのマッチングのためのクラスです。 ユーザがこのクラスを直接使うことはありません。

require 'rinda/rinda'

template = Rinda::Template.new(['abc', nil, nil])
template.match(['abc', 2, 5])   # => true
template.match(['hoge', 2, 5])  # => false

template = Rinda::Template.new([String, Integer, nil])
template.match(['abc', 2, 5])   # => true
template.match(['abcd', 2, 5])  # => true

template = Rinda::Template.new([/^abc/, Integer, nil])
template.match([/^abc/, Integer, nil])  # => true
template.match(['abc', 2, 5])           # => true
template.match(['def', 2, 5])           # => false

template = Rinda::Template.new({'name' => String, 'age' => Integer})
template.match({'name' => 'seki', 'age' => 0x20})   # => true
template.match({'name' => :seki,  'age' => 0x20})   # => false

インスタンスメソッド

self === tuple
match(tuple)

[TODO]

self と tuple のサイズが同じで、 self の各要素が tuple にマッチする場合は真を返します。 マッチングの検査には Rinda::Tuple#==Rinda::Tuple#=== を用います。 nil はワイルドカードです。

class Rinda::Template