Class: LedgerGen::Posting
- Inherits:
-
Object
- Object
- LedgerGen::Posting
- Extended by:
- T::Sig
- Defined in:
- lib/ledger_gen/posting.rb
Instance Method Summary collapse
- #account(account) ⇒ Object
- #amount(amount) ⇒ Object
- #amount_string ⇒ Object
-
#initialize ⇒ Posting
constructor
A new instance of Posting.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Posting
Returns a new instance of Posting.
8 9 10 11 |
# File 'lib/ledger_gen/posting.rb', line 8 def initialize @account = T.let('', String) @amount = T.let(nil, T.nilable(Numeric)) end |
Instance Method Details
#account(account) ⇒ Object
14 15 16 |
# File 'lib/ledger_gen/posting.rb', line 14 def account(account) @account = account end |
#amount(amount) ⇒ Object
19 20 21 |
# File 'lib/ledger_gen/posting.rb', line 19 def amount(amount) @amount = amount end |
#amount_string ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/ledger_gen/posting.rb', line 29 def amount_string if @amount.nil? '' else sprintf('$%0.2f', @amount) end end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/ledger_gen/posting.rb', line 24 def to_s "#{@account} #{amount_string}" end |