Class: Changi::Reader::CategoryReader

Inherits:
StringReader show all
Defined in:
lib/changi/reader/category_reader.rb

Instance Method Summary collapse

Instance Method Details

#read(attribute, owner) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/changi/reader/category_reader.rb', line 4

def read attribute, owner
  raise 'CategoryReader can only be used for Entry attributes.' unless owner.is_a? Entry

  cli.say "#{attribute[:name].capitalize}:\n"
  cli.choose do |menu|
    menu.choices(*categories(owner.entry_set))
    menu.choice 'Other (create new)' do
      cli.ask "Please insert #{attribute[:name]}:"
    end
    menu.choice('Abort') { exit }
  end
end