Sha256: 63772ddc8d9f3ed68de710e0830b78615e70ce20c3f9c47c2abf5db355aca5d6
Contents?: true
Size: 845 Bytes
Versions: 1
Compression:
Stored size: 845 Bytes
Contents
require 'noty/ask' module Noty module UI module_function 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
noty-0.1.1 | lib/noty/ui.rb |