Class: JournalEntry
- Inherits:
-
Object
- Object
- JournalEntry
- Defined in:
- lib/journal_entry.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#date ⇒ Object
Returns the value of attribute date.
-
#entry ⇒ Object
Returns the value of attribute entry.
-
#key ⇒ Object
Returns the value of attribute key.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(_key, _data) ⇒ JournalEntry
constructor
A new instance of JournalEntry.
- #raw ⇒ Object
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(/@#{}$/,'') end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/journal_entry.rb', line 2 def data @data end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/journal_entry.rb', line 2 def date @date end |
#entry ⇒ Object
Returns the value of attribute entry.
2 3 4 |
# File 'lib/journal_entry.rb', line 2 def entry @entry end |
#key ⇒ Object
Returns the value of attribute key.
2 3 4 |
# File 'lib/journal_entry.rb', line 2 def key @key end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
2 3 4 |
# File 'lib/journal_entry.rb', line 2 def @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
#raw ⇒ Object
20 21 22 |
# File 'lib/journal_entry.rb', line 20 def raw return data end |