Class: JournalEntry

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_key, _data) ⇒ JournalEntry

Returns a new instance of JournalEntry.



12
13
14
15
16
17
18
# File 'lib/journal_entry.rb', line 12

def initialize(_key, _data)
  @key = _key
  @data = _data
  @timestamp = _data.split('@').last
  @date = Time.at(@timestamp.to_i).to_datetime
  @entry = _data.gsub(/@#{timestamp}$/,'')
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'lib/journal_entry.rb', line 2

def data
  @data
end

#dateObject

Returns the value of attribute date.



2
3
4
# File 'lib/journal_entry.rb', line 2

def date
  @date
end

#entryObject

Returns the value of attribute entry.



2
3
4
# File 'lib/journal_entry.rb', line 2

def entry
  @entry
end

#keyObject

Returns the value of attribute key.



2
3
4
# File 'lib/journal_entry.rb', line 2

def key
  @key
end

#timestampObject

Returns the value of attribute timestamp.



2
3
4
# File 'lib/journal_entry.rb', line 2

def timestamp
  @timestamp
end

Class Method Details

.from_array(_key, _array) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/journal_entry.rb', line 4

def self.from_array(_key, _array)
  _arr = Array.new
  _array.each do |entry|
    _arr << JournalEntry.new(_key, entry)
  end
  return _arr
end

Instance Method Details

#rawObject



20
21
22
# File 'lib/journal_entry.rb', line 20

def raw
  return data
end