Class: MatchData
- Inherits:
-
Object
- Object
- MatchData
- Defined in:
- documented/common/class_exts/matchdata.rb
Overview
Extension to the MatchData class This class adds additional functionality to the MatchData class, allowing conversion to a structured format.
Instance Method Summary collapse
-
#to_hash ⇒ Hash
Converts the MatchData object to a hash.
-
#to_struct ⇒ OpenStruct
Converts the MatchData object to an OpenStruct.
Instance Method Details
#to_hash ⇒ Hash
Converts the MatchData object to a hash. captures as values.
22 23 24 25 26 |
# File 'documented/common/class_exts/matchdata.rb', line 22 def to_hash Hash[self.names.zip(self.captures.map(&:strip).map do |capture| if capture.is_i? then capture.to_i else capture end end)] end |
#to_struct ⇒ OpenStruct
Converts the MatchData object to an OpenStruct.
12 13 14 |
# File 'documented/common/class_exts/matchdata.rb', line 12 def to_struct OpenStruct.new to_hash end |