Class: ExtrasDeCont::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/extras_de_cont/transaction.rb

Overview

Models a simple bank transaction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, description, amount, currency, **options) ⇒ Transaction

Returns a new instance of Transaction.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/extras_de_cont/transaction.rb', line 10

def initialize(
  date,
  description,
  amount,
  currency,
  **options
)
  @date = date
  @description = description
  @amount = amount
  @currency = currency
  @state = options[:state]
  @deduplication_key = options[:deduplication_key] || build_deduplication_key
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/extras_de_cont/transaction.rb', line 8

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



8
9
10
# File 'lib/extras_de_cont/transaction.rb', line 8

def currency
  @currency
end

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/extras_de_cont/transaction.rb', line 8

def date
  @date
end

#deduplication_keyObject (readonly)

Returns the value of attribute deduplication_key.



8
9
10
# File 'lib/extras_de_cont/transaction.rb', line 8

def deduplication_key
  @deduplication_key
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/extras_de_cont/transaction.rb', line 8

def description
  @description
end

#stateObject (readonly)

Returns the value of attribute state.



8
9
10
# File 'lib/extras_de_cont/transaction.rb', line 8

def state
  @state
end

Instance Method Details

#reverted?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/extras_de_cont/transaction.rb', line 25

def reverted?
  state.to_s.casecmp?("REVERTED")
end