Class: Journala::Entry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Entry

Returns a new instance of Entry.



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

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

Instance Attribute Details

#confirmedObject

Returns the value of attribute confirmed.



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

def confirmed
  @confirmed
end

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#rowsObject

Returns the value of attribute rows.



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

def rows
  @rows
end

Instance Method Details

#<<(new_row) ⇒ Object



12
13
14
# File 'lib/journala/entry.rb', line 12

def <<(new_row)
  @rows << new_row
end

#to_sObject



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

def to_s
  confirmed_str = @confirmed? " *" : ""
  %{#{@date}#{confirmed_str} #{@description}\n#{@rows.collect(&:to_s).join("\n")}}
end