Class: Journala::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/journala/row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Row

Returns a new instance of Row.



6
7
8
9
10
# File 'lib/journala/row.rb', line 6

def initialize(attrs={})
  attrs.each do |k,v|
    self.send("#{k}=", v)
  end
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



3
4
5
# File 'lib/journala/row.rb', line 3

def 
  @account
end

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/journala/row.rb', line 4

def amount
  @amount
end

Instance Method Details

#to_sObject



20
21
22
23
# File 'lib/journala/row.rb', line 20

def to_s
  spaces = ' ' * [(70 - @account.length - @amount.length), 5].max
  "    #{@account}#{spaces}#{@amount}"
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/journala/row.rb', line 16

def valid?
  @account.present? && @amount.present?
end