Sha256: dcbf628d76016649fc99c61760d97431d02a9a94aa592bebf19feb4dd41badbc
Contents?: true
Size: 831 Bytes
Versions: 4
Compression:
Stored size: 831 Bytes
Contents
module Net module IP class Rule class Parser # Parse a rule entry into a hash # # @param line {String} # @return {Hash} def self.parse_line(line) params = {} params[:priority] = $1 if line =~ /^(\d+):\t/ params[:from] = $1 if line =~ /\s+from\s+([^\s]+)\s+/ params[:to] = $1 if line =~ /\s+to\s+([^\s]+)\s+/ params[:lookup] = $1 if line =~ /\s+lookup\s+([^\s]+)\s+/ params[:realms] = $1 if line =~ /\s+realms\s+([^\s]+)\s+/ params[:map_to] = $1 if line =~ /\s+map-to\s+([^\s]+)\s+/ params end def self.parse(data) list = [] data.split("\n").each do |line| list << parse_line(line) end list end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
net-ip-0.0.8 | lib/net/ip/rule/parser.rb |
net-ip-0.0.7 | lib/net/ip/rule/parser.rb |
net-ip-0.0.6 | lib/net/ip/rule/parser.rb |
net-ip-0.0.5 | lib/net/ip/rule/parser.rb |