Class: Changi::EntrySet
- Inherits:
-
Object
- Object
- Changi::EntrySet
- Defined in:
- lib/changi/entry_set.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #destroy_all ⇒ Object
- #entries ⇒ Object
- #entries_by_category ⇒ Object
-
#initialize(config) ⇒ EntrySet
constructor
A new instance of EntrySet.
- #new_entry ⇒ Object
- #previous_categories ⇒ Object
Constructor Details
#initialize(config) ⇒ 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
#config ⇒ Object (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_all ⇒ Object
28 29 30 |
# File 'lib/changi/entry_set.rb', line 28 def destroy_all entries.each &:destroy end |
#entries ⇒ Object
16 17 18 |
# File 'lib/changi/entry_set.rb', line 16 def entries @entries ||= yamls.map { |yml| Entry.load self, yml } end |
#entries_by_category ⇒ Object
20 21 22 |
# File 'lib/changi/entry_set.rb', line 20 def entries_by_category entries.group_by &:category end |
#new_entry ⇒ Object
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_categories ⇒ Object
24 25 26 |
# File 'lib/changi/entry_set.rb', line 24 def previous_categories entries.map &:category end |