Class: MatchData
- Inherits:
-
Object
- Object
- MatchData
- Defined in:
- documented/common/class_exts/matchdata.rb
Overview
Represents a match data object that contains information about a regular expression match.
Instance Method Summary collapse
-
#to_hash ⇒ Hash
Converts the match data to a hash.
-
#to_struct ⇒ OpenStruct
Converts the match data to an OpenStruct object.
Instance Method Details
#to_hash ⇒ Hash
Converts the match data to a hash.
18 19 20 21 22 |
# File 'documented/common/class_exts/matchdata.rb', line 18 def to_hash self.names.zip(self.captures.map(&:strip).map do |capture| if capture.is_i? then capture.to_i else capture end end).to_h end |
#to_struct ⇒ OpenStruct
Converts the match data to an OpenStruct object.
10 11 12 |
# File 'documented/common/class_exts/matchdata.rb', line 10 def to_struct OpenStruct.new to_hash end |