Class: Moneymanager::Entry
- Inherits:
-
Object
- Object
- Moneymanager::Entry
- Defined in:
- lib/moneymanager/entry.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#approved ⇒ Object
Returns the value of attribute approved.
-
#company ⇒ Object
Returns the value of attribute company.
-
#date ⇒ Object
Returns the value of attribute date.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #digest ⇒ Object
- #expense? ⇒ Boolean
- #formatted_amount ⇒ Object
- #formatted_approved ⇒ Object
- #income? ⇒ Boolean
-
#initialize ⇒ Entry
constructor
A new instance of Entry.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Entry
Returns a new instance of Entry.
6 7 8 |
# File 'lib/moneymanager/entry.rb', line 6 def initialize @approved = false end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def amount @amount end |
#approved ⇒ Object
Returns the value of attribute approved.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def approved @approved end |
#company ⇒ Object
Returns the value of attribute company.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def company @company end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def date @date end |
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def raw @raw end |
#reason ⇒ Object
Returns the value of attribute reason.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def reason @reason end |
#tag ⇒ Object
Returns the value of attribute tag.
4 5 6 |
# File 'lib/moneymanager/entry.rb', line 4 def tag @tag end |
Instance Method Details
#digest ⇒ Object
10 11 12 |
# File 'lib/moneymanager/entry.rb', line 10 def digest Digest::SHA1.hexdigest(@raw) end |
#expense? ⇒ Boolean
31 32 33 |
# File 'lib/moneymanager/entry.rb', line 31 def expense? amount < 0 end |
#formatted_amount ⇒ Object
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_approved ⇒ Object
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
35 36 37 |
# File 'lib/moneymanager/entry.rb', line 35 def income? !expense? end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/moneymanager/entry.rb', line 14 def to_s "Date: #{@date}, #{reason}, #{amount}, #{company}" end |