Module: Noty::UI
- Defined in:
- lib/noty/ui.rb
Class Method Summary collapse
Class Method Details
.choose(objects) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/noty/ui.rb', line 7 def choose(objects) return if objects.empty? if objects.one? puts objects.first.to_s(false) operations(objects.first) else objects.each_with_index do |object, index| puts "#{index + 1}. " + object.to_s(true) end choice = ask '-> (1..9) or else to exit: ' if choice =~ /\A[1-9]\z/ puts objects[choice.to_i - 1].to_s(false) operations(objects[choice.to_i - 1]) end end end |
.operations(object) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/noty/ui.rb', line 28 def operations(object) case ask '[E]dit [D]elete [O]pen [C]opy, Else to Quit: ' when 'e' object.edit when 'd' object.delete when 'o' object.open when 'c' object.copy else exit 0 end end |