Class: CLI
- Inherits:
-
Object
- Object
- CLI
- Defined in:
- lib/lazuli.rb
Instance Method Summary collapse
Instance Method Details
#dialog ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/lazuli.rb', line 84 def dialog() config = Config.new template = prompt("Template file") query = prompt("Query") items = AmazonConnector. new.fetch_items( query.to_s, config.get_access_key, config.get_secret_key, config.get_partner_tag, ) print_choices(items) selected_index = prompt("Index of product").to_i output_file = prompt("Output destination") TemplateGenerator. new(template, items[selected_index - 1], output_file) end |
#print_choices(items) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/lazuli.rb', line 70 def print_choices(items) index = 1 items.each do |item| puts index.to_s + ". " + (item["ItemInfo"]["Title"]["DisplayValue"])[0..50] index += 1 end return items end |
#prompt(prompt) ⇒ Object
79 80 81 82 |
# File 'lib/lazuli.rb', line 79 def prompt(prompt) puts "[*] " + prompt + ": " return gets.gsub("\n", '') end |