Class: Noter::NoteFile
- Inherits:
-
Object
- Object
- Noter::NoteFile
- Defined in:
- lib/noter/note_file.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
- #first_line ⇒ Object
- #formatted_time ⇒ Object
-
#initialize(filename) ⇒ NoteFile
constructor
A new instance of NoteFile.
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
#filename ⇒ Object (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
.dir ⇒ Object
9 10 11 |
# File 'lib/noter/note_file.rb', line 9 def self.dir "#{ENV['HOME']}/.notes" end |
Instance Method Details
#content ⇒ Object
19 20 21 |
# File 'lib/noter/note_file.rb', line 19 def content File.read(filename) end |
#first_line ⇒ Object
23 24 25 |
# File 'lib/noter/note_file.rb', line 23 def first_line content.split("\n")[0] end |
#formatted_time ⇒ Object
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 |