このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.1 リファレンスマニュアル

class Rinda::Template

[edit]

要約

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

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

template = Rinda::Template.new([String, Integer, nil])
p template.match(['abc', 2, 5]) # => true
p template.match(['abcd', 2, 5])  # => true
 
template = Rinda::Template.new([/^abc/, Integer, nil])
p template.match([/^abc/, Integer, nil])  # => true
p template.match(['abc', 2, 5])         # => true
p template.match(['def', 2, 5])         # => false
 
template = Rinda::Template.new({'name' => String, 'age' => Integer})
p template.match({'name' => 'seki', 'age' => 0x20}) # => true
p template.match({'name' => :seki,  'age' => 0x20}) # => false

目次

継承しているメソッド