Class: Kuromd::Folder
- Inherits:
-
Object
- Object
- Kuromd::Folder
- Defined in:
- lib/kuromd/folder.rb
Overview
Represents a folder of stuff, this object should categorize each item and have the ability to process.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#folder_path ⇒ Object
Returns the value of attribute folder_path.
-
#notes ⇒ Object
Returns the value of attribute notes.
Instance Method Summary collapse
- #build_table ⇒ Object
-
#initialize(params = {}) ⇒ Folder
constructor
A new instance of Folder.
- #process ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Folder
Returns a new instance of Folder.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kuromd/folder.rb', line 14 def initialize(params = {}) raise StandardError, 'Configuration not found' if params[:config].nil? @config = params[:config] raise StandardError, 'Journal params not found' if @config.params['journal'].nil? raise StandardError, 'Inbox params not found' if @config.params['journal']['inbox'].nil? @folder_path = @config.params['journal']['inbox'] @folder_path = File.(@folder_path) raise 'Folder not found' unless Dir.exist?(@folder_path) # TODO: test for creating the hash @notes = [] process_files end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12 13 14 |
# File 'lib/kuromd/folder.rb', line 12 def config @config end |
#folder_path ⇒ Object
Returns the value of attribute folder_path.
12 13 14 |
# File 'lib/kuromd/folder.rb', line 12 def folder_path @folder_path end |
#notes ⇒ Object
Returns the value of attribute notes.
12 13 14 |
# File 'lib/kuromd/folder.rb', line 12 def notes @notes end |
Instance Method Details
#build_table ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kuromd/folder.rb', line 30 def build_table # convert @notes into something that can be used rows = [] count = 1 @notes.each do |note| rows << [count, note[:filename], note[:note_type]] count += 1 end Terminal::Table.new do self.headings = ['index', 'Filename', 'Note type'] self.rows = rows end end |
#process ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/kuromd/folder.rb', line 45 def process @notes.each do |note| note_objects = note[:note_objs] note_objects.each do |note_object| note_object.process end end end |