Class: SimpleArgs::Match
- Inherits:
-
Object
- Object
- SimpleArgs::Match
- Defined in:
- lib/simple_args/match.rb
Instance Attribute Summary collapse
-
#matchdata ⇒ Object
readonly
Returns the value of attribute matchdata.
Class Method Summary collapse
Instance Method Summary collapse
- #captures ⇒ Object
- #deconstruct ⇒ Object
- #deconstruct_keys ⇒ Object
- #named_captures ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#matchdata ⇒ Object (readonly)
Returns the value of attribute matchdata.
6 7 8 |
# File 'lib/simple_args/match.rb', line 6 def matchdata @matchdata end |
Class Method Details
.match(rgx, subject) ⇒ Object
8 9 10 11 |
# File 'lib/simple_args/match.rb', line 8 def match(rgx, subject) m = rgx.match(subject) return new(m) if m end |
Instance Method Details
#captures ⇒ Object
14 |
# File 'lib/simple_args/match.rb', line 14 def captures = matchdata.captures |
#deconstruct ⇒ Object
19 |
# File 'lib/simple_args/match.rb', line 19 def deconstruct(*) = to_a |
#deconstruct_keys ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/simple_args/match.rb', line 20 def deconstruct_keys(*) named_captures .compact .inject({}) do |h, (k, v)| h.merge( k.to_sym => v ) end end |
#named_captures ⇒ Object
15 |
# File 'lib/simple_args/match.rb', line 15 def named_captures = matchdata.named_captures |
#to_a ⇒ Object
16 |
# File 'lib/simple_args/match.rb', line 16 def to_a = matchdata.to_a |
#to_s ⇒ Object
17 |
# File 'lib/simple_args/match.rb', line 17 def to_s = matchdata.to_s |