Class: DayOne2MD::MarkdownEntry

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/dayone2md/markdown_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/dayone2md/markdown_entry.rb', line 5

def content
  @content
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/dayone2md/markdown_entry.rb', line 5

def date
  @date
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/dayone2md/markdown_entry.rb', line 5

def title
  @title
end

Instance Method Details

#dirObject



23
24
25
# File 'lib/dayone2md/markdown_entry.rb', line 23

def dir
  @dir || Dir.pwd
end

#dir=(dir) ⇒ Object



19
20
21
# File 'lib/dayone2md/markdown_entry.rb', line 19

def dir=(dir)
  @dir = dir if dir
end

#filenameObject



9
10
11
12
13
# File 'lib/dayone2md/markdown_entry.rb', line 9

def filename
  s = [ formated_date ]
  s << formated_title if formated_title
  s.join(' ') + '.md'
end

#saveObject



15
16
17
# File 'lib/dayone2md/markdown_entry.rb', line 15

def save
  valid? ? (write_file; true) : false
end