Class: ParseITC::Transaction
- Inherits:
-
Object
- Object
- ParseITC::Transaction
- Defined in:
- lib/parseitc/transaction.rb
Constant Summary collapse
- YEAR_TWO_THOUSAND =
Date.parse("1/1/2000")
- TWO_THOUSAND_YEARS =
YEAR_TWO_THOUSAND - Date.parse("1/1/0")
Instance Attribute Summary collapse
-
#apple_identifier ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#company ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#country ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#customer_currency ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#customer_price ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#date ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#product ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#promo_code ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#provider ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#provider_country ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#royalty_currency ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#royalty_price ⇒ Object
(also: #price)
ignoring some columns that are ignored by iphone apps.
-
#units ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#vendor_identifier ⇒ Object
ignoring some columns that are ignored by iphone apps.
-
#vendor_offer_code ⇒ Object
ignoring some columns that are ignored by iphone apps.
Instance Method Summary collapse
- #has_field?(field) ⇒ Boolean
-
#initialize(array) ⇒ Transaction
constructor
A new instance of Transaction.
- #price_tier ⇒ Object
Constructor Details
#initialize(array) ⇒ Transaction
Returns a new instance of Transaction.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/parseitc/transaction.rb', line 25 def initialize array raise WrongNumberOfElements.new(27, array.length) unless array.length == 27 @provider = array[0] @provider_country = array[1] @company = array[5] @product = array[6] @vendor_identifier = array[2] @date = Date.parse(array[11]) @product_type_id = array[8] # 1 = new, 7 = update @units = array[9] @royalty_price = array[10] @royalty_currency = array[15] @customer_price = array[20] @customer_currency = array[13] @vendor_offer_code = array[23] @promo_code = array[25] @country = array[14] @apple_identifier = array[19] # Adjust date if necessary ("1/5/10" should not be 10 A.D.) @date += TWO_THOUSAND_YEARS if @date < YEAR_TWO_THOUSAND raise PriceTierNotFound.new(royalty_price, royalty_currency) unless price_tier end |
Instance Attribute Details
#apple_identifier ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def apple_identifier @apple_identifier end |
#company ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def company @company end |
#country ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def country @country end |
#customer_currency ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def customer_currency @customer_currency end |
#customer_price ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def customer_price @customer_price end |
#date ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def date @date end |
#product ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def product @product end |
#promo_code ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def promo_code @promo_code end |
#provider ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def provider @provider end |
#provider_country ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def provider_country @provider_country end |
#royalty_currency ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def royalty_currency @royalty_currency end |
#royalty_price ⇒ Object Also known as: price
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def royalty_price @royalty_price end |
#units ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def units @units end |
#vendor_identifier ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def vendor_identifier @vendor_identifier end |
#vendor_offer_code ⇒ Object
ignoring some columns that are ignored by iphone apps
7 8 9 |
# File 'lib/parseitc/transaction.rb', line 7 def vendor_offer_code @vendor_offer_code end |
Instance Method Details
#has_field?(field) ⇒ Boolean
62 63 64 |
# File 'lib/parseitc/transaction.rb', line 62 def has_field? field (instance_variables.map{|variable| variable[1..-1]} + public_methods).include? field end |
#price_tier ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/parseitc/transaction.rb', line 49 def price_tier @price_tier ||= begin prices = ApplePricing[@royalty_currency.downcase.to_sym] if @customer_price.to_f == 0 0 else prices.find_index(@royalty_price.to_f) end rescue nil end end |