Class: MatchData

Inherits:
Object
  • Object
show all
Defined in:
lib/Olib/ext/matchdata.rb

Instance Method Summary collapse

Instance Method Details

#to_hObject



9
10
11
12
13
# File 'lib/Olib/ext/matchdata.rb', line 9

def to_h
  Hash[self.names.map(&:to_sym).zip(self.captures.map(&:strip).map do |capture|  
    if capture.is_i? then capture.delete(",").to_i else capture end
  end)]
end

#to_structObject



5
6
7
# File 'lib/Olib/ext/matchdata.rb', line 5

def to_struct
  OpenStruct.new to_h
end