module NRB::Support::PackageTypeParser
Public Instance Methods
parse_package_type(string, type_class: String)
click to toggle source
# File lib/nrb/support/package_type_parser.rb, line 4 def parse_package_type(string, type_class: String) return nil if string.nil? matched = match_package_type(string) return type_class.new(matched) if matched end
Private Instance Methods
match_package_type(string)
click to toggle source
# File lib/nrb/support/package_type_parser.rb, line 12 def match_package_type(string) if string =~ /bbl/i 'keg' elsif string =~ /can\s+case/i 'can' elsif string =~ /22\s*oz/i || string =~ /750\s*ml/i 'bottle' end end