Class: BillingLogic::CommandBuilders::ProductList

Inherits:
Object
  • Object
show all
Defined in:
lib/billing_logic/command_builders/command_builders.rb

Class Method Summary collapse

Class Method Details

.parse(string, options = {}) ⇒ Object

ProductList.parse returns a dumb array You can’t add behavior (I tried adding #price)



16
17
18
19
20
21
22
23
24
# File 'lib/billing_logic/command_builders/command_builders.rb', line 16

def self.parse(string, options = {})
  if (products = (string =~ /\(([^\(\)]*)\)/) ? $1 : nil)
    products.split(/ & /).map do |product_string|
      ProductStub.parse(product_string, options)
    end
  else
    []
  end
end