Class: Noter::NoteFile

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ NoteFile

Returns a new instance of NoteFile.



5
6
7
# File 'lib/noter/note_file.rb', line 5

def initialize(filename)
  @filename = filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/noter/note_file.rb', line 3

def filename
  @filename
end

Class Method Details

.dirObject



9
10
11
# File 'lib/noter/note_file.rb', line 9

def self.dir
  "#{ENV['HOME']}/.notes"
end

Instance Method Details

#contentObject



19
20
21
# File 'lib/noter/note_file.rb', line 19

def content
  File.read(filename)
end

#first_lineObject



23
24
25
# File 'lib/noter/note_file.rb', line 23

def first_line
  content.split("\n")[0]
end

#formatted_timeObject



13
14
15
16
17
# File 'lib/noter/note_file.rb', line 13

def formatted_time
  basename = File.basename(@filename, ".txt")
  numbers = basename.split("_")
  "#{numbers[1]}-#{numbers[2]} #{numbers[3]}:#{numbers[4]}"
end