Class: Amex::Transaction
- Inherits:
-
Object
- Object
- Amex::Transaction
- Defined in:
- lib/amex/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#extra_details ⇒ Object
readonly
Returns the value of attribute extra_details.
-
#narrative ⇒ Object
readonly
Returns the value of attribute narrative.
Instance Method Summary collapse
-
#initialize(transaction) ⇒ Amex::Transaction
constructor
Generates an Amex::LoyaltyProgramme object from a Nokogiri object representing <Transaction> element.
-
#is_foreign_transaction? ⇒ Boolean
Returns whether the transaction was made abroad/in a foreign currency.
Constructor Details
#initialize(transaction) ⇒ Amex::Transaction
Generates an Amex::LoyaltyProgramme object from a Nokogiri object representing <Transaction> element
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/amex/transaction.rb', line 15 def initialize(transaction) # Pass this a <Transaction> element, and it'll parse it @date = Date.strptime(transaction.css('TransChargeDate').text, '%m/%d/%y') @narrative = transaction.css('TransDesc').text @amount = transaction.css('TransAmount').text.to_f @extra_details = {} transaction.css('TransExtDetail ExtDetailElement').each do |element| @extra_details[element.attr('name')] = element.attr('formattedValue') end end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
5 6 7 |
# File 'lib/amex/transaction.rb', line 5 def amount @amount end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
5 6 7 |
# File 'lib/amex/transaction.rb', line 5 def date @date end |
#extra_details ⇒ Object (readonly)
Returns the value of attribute extra_details.
5 6 7 |
# File 'lib/amex/transaction.rb', line 5 def extra_details @extra_details end |
#narrative ⇒ Object (readonly)
Returns the value of attribute narrative.
5 6 7 |
# File 'lib/amex/transaction.rb', line 5 def narrative @narrative end |
Instance Method Details
#is_foreign_transaction? ⇒ Boolean
Returns whether the transaction was made abroad/in a foreign currency
32 33 34 35 |
# File 'lib/amex/transaction.rb', line 32 def is_foreign_transaction? return true if @extra_details.has_key?('currencyRate') false end |