Class: Any
- Inherits:
-
Object
- Object
- Any
- 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, Any[{:color => 'blue'}, {:color => 'red'}], /Hello/]
print foo
end
Class Method Summary collapse
Instance Method Summary collapse
- #===(obj) ⇒ Object
-
#initialize(*patterns) ⇒ Any
constructor
A new instance of Any.
Constructor Details
#initialize(*patterns) ⇒ Any
Returns a new instance of Any.
1360 1361 1362 |
# File 'lib/magic_xml.rb', line 1360 def initialize(*patterns) @patterns = patterns end |
Class Method Details
.[](*patterns) ⇒ Object
1366 1367 1368 |
# File 'lib/magic_xml.rb', line 1366 def self.[](*patterns) new(*patterns) end |
Instance Method Details
#===(obj) ⇒ Object
1363 1364 1365 |
# File 'lib/magic_xml.rb', line 1363 def ===(obj) @patterns.any?{|p| p === obj} end |