Class: BillingLogic::CommandBuilders::ProductStub

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#billing_cycleObject

Returns the value of attribute billing_cycle.



28
29
30
# File 'lib/billing_logic/command_builders/command_builders.rb', line 28

def billing_cycle
  @billing_cycle
end

#identifierObject

Returns the value of attribute identifier.



28
29
30
# File 'lib/billing_logic/command_builders/command_builders.rb', line 28

def identifier
  @identifier
end

#initial_paymentObject

Returns the value of attribute initial_payment.



28
29
30
# File 'lib/billing_logic/command_builders/command_builders.rb', line 28

def initial_payment
  @initial_payment
end

#nameObject

Returns the value of attribute name.



28
29
30
# File 'lib/billing_logic/command_builders/command_builders.rb', line 28

def name
  @name
end

#paymentsObject

Returns the value of attribute payments.



28
29
30
# File 'lib/billing_logic/command_builders/command_builders.rb', line 28

def payments
  @payments
end

#priceObject

Returns the value of attribute price.



28
29
30
# File 'lib/billing_logic/command_builders/command_builders.rb', line 28

def price
  @price
end

Class Method Details

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



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/billing_logic/command_builders/command_builders.rb', line 29

def self.parse(string, options = {})
  string =~ /#{BillingLogic::CommandBuilders::SINGLE_PRODUCT_REGEX}/
  billing_cycle = $3 ? ::BillingLogic::BillingCycle.new(:frequency => 1, :period => $3.include?('mo') ? :month : :year) : nil
  product = (options[:product_class] || self).new
  product.name = $1
  product.price = Float($2)
  product.identifier = "#{$1} @ $#{$2}#{$3}"
  product.billing_cycle = billing_cycle
  product.initial_payment = options[:initial_payment] || 0
  product
end