Class: Moneymanager::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/moneymanager/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEntry

Returns a new instance of Entry.



6
7
8
# File 'lib/moneymanager/entry.rb', line 6

def initialize
  @approved = false
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def amount
  @amount
end

#approvedObject

Returns the value of attribute approved.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def approved
  @approved
end

#companyObject

Returns the value of attribute company.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def company
  @company
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def date
  @date
end

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def raw
  @raw
end

#reasonObject

Returns the value of attribute reason.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def reason
  @reason
end

#tagObject

Returns the value of attribute tag.



4
5
6
# File 'lib/moneymanager/entry.rb', line 4

def tag
  @tag
end

Instance Method Details

#digestObject



10
11
12
# File 'lib/moneymanager/entry.rb', line 10

def digest
  Digest::SHA1.hexdigest(@raw)
end

#expense?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/moneymanager/entry.rb', line 31

def expense?
  amount < 0
end

#formatted_amountObject



26
27
28
29
# File 'lib/moneymanager/entry.rb', line 26

def formatted_amount
  s = amount.to_s + ''
  amount < 0 ? s.red : s.green
end

#formatted_approvedObject



18
19
20
21
22
23
24
# File 'lib/moneymanager/entry.rb', line 18

def formatted_approved
  if approved
    '✔︎'.green
  else
    '✖︎'.red
  end
end

#income?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/moneymanager/entry.rb', line 35

def income?
  !expense?
end

#to_sObject



14
15
16
# File 'lib/moneymanager/entry.rb', line 14

def to_s
  "Date: #{@date}, #{reason}, #{amount}, #{company}"
end