Class: Tinypass::Offer

Inherits:
Object
  • Object
show all
Defined in:
lib/tinypass/offer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, *price_options_or_policy) ⇒ Offer

Returns a new instance of Offer.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tinypass/offer.rb', line 5

def initialize(resource, *price_options_or_policy)
  raise ArgumentError.new("Can't initialize offer without price options or policy") if price_options_or_policy.empty?

  @resource = resource
  @policies = []
  @tags = []

  if price_options_or_policy.first.kind_of?(PricingPolicy)
    @pricing = price_options_or_policy.first
  else
    @pricing = PricingPolicy.new(price_options_or_policy)
  end
end

Instance Attribute Details

#policiesObject (readonly)

Returns the value of attribute policies.



3
4
5
# File 'lib/tinypass/offer.rb', line 3

def policies
  @policies
end

#pricingObject (readonly)

Returns the value of attribute pricing.



3
4
5
# File 'lib/tinypass/offer.rb', line 3

def pricing
  @pricing
end

#resourceObject (readonly)

Returns the value of attribute resource.



3
4
5
# File 'lib/tinypass/offer.rb', line 3

def resource
  @resource
end

#tagsObject (readonly)

Returns the value of attribute tags.



3
4
5
# File 'lib/tinypass/offer.rb', line 3

def tags
  @tags
end

Instance Method Details

#has_active_prices?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/tinypass/offer.rb', line 19

def has_active_prices?
  pricing.has_active_options?
end