Class: Regexp
- Includes:
- PatternMatch::Deconstructable
- Defined in:
- lib/pattern-match/deconstructor.rb
Instance Method Summary collapse
Methods included from PatternMatch::Deconstructable
Instance Method Details
#deconstruct(val) ⇒ Object
55 56 57 58 59 |
# File 'lib/pattern-match/deconstructor.rb', line 55 def deconstruct(val) m = Regexp.new("\\A#{source}\\z", ).match(val.to_s) raise PatternMatch::PatternNotMatch unless m m.captures.empty? ? [m[0]] : m.captures end |