Class: Transaction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Transaction

Returns a new instance of Transaction.



4
5
6
7
8
9
# File 'lib/cartolify/transaction.rb', line 4

def initialize(hash)
	@total = hash[:total]
	@date = hash[:date]
	@description = clean_utf(hash[:description])
	@saldo = hash[:saldo]
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



2
3
4
# File 'lib/cartolify/transaction.rb', line 2

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



2
3
4
# File 'lib/cartolify/transaction.rb', line 2

def description
  @description
end

#saldoObject (readonly)

Returns the value of attribute saldo.



2
3
4
# File 'lib/cartolify/transaction.rb', line 2

def saldo
  @saldo
end

#totalObject (readonly)

Returns the value of attribute total.



2
3
4
# File 'lib/cartolify/transaction.rb', line 2

def total
  @total
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/cartolify/transaction.rb', line 2

def type
  @type
end

Instance Method Details

#income?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cartolify/transaction.rb', line 11

def income?
	total > 0
end

#outcome?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/cartolify/transaction.rb', line 15

def outcome?
	total < 0
end