class ItemMenu
Attributes
cli[RW]
Public Class Methods
new(cli)
click to toggle source
# File lib/dexter_plusplus/item_menu.rb, line 4 def initialize(cli) self.cli = cli end
Public Instance Methods
display_item_options(options)
click to toggle source
# File lib/dexter_plusplus/item_menu.rb, line 66 def display_item_options(options) options.unshift("Exit Dexter++".light_red) options.unshift("Go back to main menu".light_green) choice = self.cli.get_menu_from_array(options) if choice == "Exit Dexter++".light_red self.exit elsif choice == "Go back to main menu".light_green self.main_menu else item = API.get_item_by_name(choice.downcase) puts "\n\n\n" item.print_all end puts "\n\n" self.main_menu end
get_random()
click to toggle source
# File lib/dexter_plusplus/item_menu.rb, line 49 def get_random item = API.get_random_item item.print_all puts"\n\n" self.main_menu end
list_items()
click to toggle source
# File lib/dexter_plusplus/item_menu.rb, line 31 def list_items puts "\n\nHow many items would you like to list?" input = gets.strip.to_i until input.between?(1, Item.limit) if input <= 0 puts"\nThat is not enough Items! Try a bigger number" input = gets.strip.to_i else puts "\nThats way too many Items! Try a smaller number." input = gets.strip.to_i end end puts "\n\nAwesome! Let me load that for you." puts"\n\n" options = Item.find_with_offset_and_limit(rand(0...Item.limit), input) self.display_item_options(options) end
search_by_name()
click to toggle source
# File lib/dexter_plusplus/item_menu.rb, line 56 def search_by_name puts "\n\nWhat Item would you like to search for?" input = gets.strip.downcase puts "\n\nAwesome! Let me load that for you." item = API.get_item_by_name(input) item.print_all puts"\n\n" self.main_menu end