Class: Changi::EntrySet

Inherits:
Object
  • Object
show all
Defined in:
lib/changi/entry_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ EntrySet

Returns a new instance of EntrySet.



7
8
9
10
# File 'lib/changi/entry_set.rb', line 7

def initialize config
  @config = config
  FileUtils.mkdir_p @config.entries_path
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/changi/entry_set.rb', line 5

def config
  @config
end

Instance Method Details

#destroy_allObject



24
25
26
# File 'lib/changi/entry_set.rb', line 24

def destroy_all
  entries.each(&:destroy)
end

#entriesObject



16
17
18
# File 'lib/changi/entry_set.rb', line 16

def entries
  @entries ||= yamls.map { |yml| Entry.load self, yml }
end

#new_entryObject



12
13
14
# File 'lib/changi/entry_set.rb', line 12

def new_entry
  entries << Entry.build(self, make_entry_path).tap(&:save)
end

#previous_categoriesObject



20
21
22
# File 'lib/changi/entry_set.rb', line 20

def previous_categories
  entries.map(&:category)
end