Could you please review the following class products?
It should tell me whether the product is taxable or imported. Name should indicate if the product is imported or certain keywords should tell that the product is non-taxable (chocolates, book, pills)
class Product
NON_TAXABLE = [/chocolates/, /book/, /pills/]
def initialize(product_name)
@product_name = product_name
end
def is_taxable?
taxable = false
NON_TAXABLE.each { |x| taxable = x.match(@product_name) if taxable }
!taxable
end
def is_imported?
/imported/.match(@product_name)
end
end