Class: Patterns_all

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_xml.rb

Overview

Perl 6 is supposed to have native support for something like that. Constructor takes multiple patterns. The object matches if they all match.

Usage:

case foo
when all(:foo, {:color => 'blue'}, /Hello/)
     print foo
end

Instance Method Summary collapse

Constructor Details

#initialize(*patterns) ⇒ Patterns_all

Returns a new instance of Patterns_all.



1348
1349
1350
# File 'lib/magic_xml.rb', line 1348

def initialize(*patterns)
    @patterns = patterns
end

Instance Method Details

#===(obj) ⇒ Object



1351
1352
1353
# File 'lib/magic_xml.rb', line 1351

def ===(obj)
    @patterns.all?{|p| p === obj}
end