cmd_matcher

command line response to hash

usage:

cm = CmdMatcher.new cm.has_one “++++++++++++++++++++++++++++++++++” cm.has_one “sn type id” cm.has_one “++++++++++++++++++++++++++++++++++” cm.has_many /(d+)s+(trunk|access)s+(d+)/, :names => [:sn, :type, :id] cm.has “++++++++++++++++++++++++++++++++++”, :at_most => 1 cm.has_one /totals*(d+)/, :names => [:total]

cm.match(%Qsn type id ++++++++++++++++++++++++++++++++++ 1 trunk 100 2 access 200 ++++++++++++++++++++++++++++++++++ total 2

)

puts cm.matches puts cm.matches[0] puts cm.matches[1]