class DayoneToolbox::Entry

Constants

KEY_CREATION_DATE
KEY_CREATOR
KEY_ENTRY_TEXT
KEY_LOCATION
KEY_STARRED
KEY_TAGS
KEY_TIME_ZONE
KEY_UUID
KEY_WEATHER

Attributes

file[R]
journal_dir[R]

Public Class Methods

entry_attributes() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 14
def self.entry_attributes
  {
    "tags" => KEY_TAGS,
    "uuid" => KEY_UUID,
    "entry_text" => KEY_ENTRY_TEXT,
    "creation_date" => KEY_CREATION_DATE,
    "creator" => KEY_CREATOR,
    "starred" => KEY_STARRED,
    "time_zone" => KEY_TIME_ZONE,
    "location" => KEY_LOCATION,
    "weather" => KEY_WEATHER
  }
end
new(file) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 30
def initialize(file)
  @file = File.expand_path(file)
  @journal_dir = nil
  Pathname.new(file).ascend do |v|
    @journal_dir =  v.expand_path.to_s if v.basename.to_s.match('.dayone')
  end
  @hash = Plist.parse_xml(@file)
end

Public Instance Methods

creation_date() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 62
def creation_date ; @hash[KEY_CREATION_DATE] ; end
creation_date=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 63
def creation_date=(attr) ; @hash[KEY_CREATION_DATE] = attr ; end
creation_date?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 64
def creation_date? ; @hash.has_key?(KEY_CREATION_DATE) ; end
creator() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 66
def creator ; @hash[KEY_CREATOR] ; end
creator=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 67
def creator=(attr) ; @hash[KEY_CREATOR] = attr ; end
creator?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 68
def creator? ; @hash.has_key?(KEY_CREATOR) ; end
custom_key(key) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 95
def custom_key(key)
  @hash[key]
end
custom_key?(key) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 99
def custom_key?(key)
  @hash.has_key?("#{key}")
end
entry_text() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 58
def entry_text ; @hash[KEY_ENTRY_TEXT] ; end
entry_text=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 59
def entry_text=(attr) ; @hash[KEY_ENTRY_TEXT] = attr ; end
entry_text?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 60
def entry_text? ; @hash.has_key?(KEY_ENTRY_TEXT) ; end
location() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 78
def location ; @hash[KEY_LOCATION] ; end
location=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 79
def location=(attr) ; @hash[KEY_LOCATION] = attr ; end
location?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 80
def location? ; @hash.has_key?(KEY_LOCATION) ; end
photo() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 86
def photo
  jpg = File.join("#{@journal_dir}", "photos/#{uuid}.jpg")
  File.exist?(jpg) ? jpg.to_s : nil
end
photo?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 91
def photo?
  photo ? true : false
end
set_custom_key(key, value) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 103
def set_custom_key(key, value)
  @hash["#{key}"] = value
end
starred() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 70
def starred ; @hash[KEY_STARRED] ; end
starred=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 71
def starred=(attr) ; @hash[KEY_STARRED] = attr ; end
starred?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 72
def starred? ; @hash.has_key?(KEY_STARRED) ; end
tags() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 50
def tags ; @hash[KEY_TAGS] ; end
tags=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 51
def tags=(attr) ; @hash[KEY_TAGS] = attr ; end
tags?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 52
def tags? ; @hash.has_key?(KEY_TAGS) ; end
time_zone() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 74
def time_zone ; @hash[KEY_TIME_ZONE] ; end
time_zone=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 75
def time_zone=(attr) ; @hash[KEY_TIME_ZONE] = attr ; end
time_zone?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 76
def time_zone? ; @hash.has_key?(KEY_TIME_ZONE) ; end
to_h() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 45
def to_h
  @hash
end
to_plist() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 40
def to_plist
  @hash.to_plist
end
uuid() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 54
def uuid ; @hash[KEY_UUID] ; end
uuid=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 55
def uuid=(attr) ; @hash[KEY_UUID] = attr ; end
uuid?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 56
def uuid? ; @hash.has_key?(KEY_UUID) ; end
weather() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 82
def weather ; @hash[KEY_WEATHER] ; end
weather=(attr) click to toggle source
# File lib/dayone_toolbox/entry.rb, line 83
def weather=(attr) ; @hash[KEY_WEATHER] = attr ; end
weather?() click to toggle source
# File lib/dayone_toolbox/entry.rb, line 84
def weather? ; @hash.has_key?(KEY_WEATHER) ; end