Speed up development with full-stack environments for every branch.

Learn More

Lunch ROI calculator [Ruby]

Forked from Basic Ruby Example.

17 Runs 103 Views 7 Copies
Saved

Saved

arledgemike 8

arledgemike
published 3 years ago

require 'twitter'
require 'nokogiri'
require 'open-uri'
require 'artii'

class LunchDex
  
  def initialize
    @sum = 0
    @arr = []
    @delete = [1,2,3,4,5, 16, 17, 18, 19, 20, 23, 28, 31, 40, 54, 55, 120]
    @doc = Nokogiri::HTML(open('http://chicago.menupages.com/restaurants/steves-place/menu'))
    @el = @doc.css '#restaurant-menu table tbody tr cite'
    
    
    puts "           ----- BOBDOTCOM.BIZ PRESENTS ----- \n"
    
    @file = File.open "bob.txt"
    @file.each_line do |x|
      puts "#{x}"
    end
    
    a = Artii::Base.new 
    puts a.asciify('LunchDex')
    puts "LunchDex is a hashtag return on investment (ROI) calculator. \n\n"
    puts "LunchDex checks your hashtags against the SPXchange to determine\nyour lunch time ROI if you were to include those tags in a pre-lunch status/tweet update."
    puts "\nWhat hashtags should we calculate.
    \n(example: #ideate, #insights, #realtime)\n"
    print "---------->"
    @hashes = gets.chomp.split ","
  
  
    client = Twitter::REST::Client.new do |config|
      config.consumer_key        = "818sKSSBcvMRET5sZUOXTg" #ENV["CONSUMER_KEY"]
      config.consumer_secret     = "hTnZxLFJ0lLWyvMEyOrEOy0I69oGaYvq7rcpgTumAW8" #ENV["CONSUMER_SECRET"]
    end
  
    @hashes.each do |x|
      el = client.search "#{x}"
      @sum = el.count + @sum
      puts "Calculating................\n"
    end
  
    @el.each do |x|
      @arr << x.content
    end
  
    @delete.each_with_index do |x, i|
      n = x.to_i - i
      @arr.delete_at n
      puts "Extrapolating real time figures................\n"
    end
  
   puts "We have finished calculating your ROI.\n\nIf you include these hashtags in a pre-lunch post/tweet your return should be a"
  
    if @sum > @arr.count
      x = @sum % @arr.count
      puts "----------> [email protected][x]}\n\n"
    else
       puts "---------> [email protected][@sum]}\n\n"
    end
    
    puts "A sample facebook status could read:\n"
    puts "Sitting in a business meeting wating for lunch [email protected](",")}"         
    
   puts "\n\nIf you want to visit the exchange it is located at 230 W. Chicago and is open regular business hours. \n\nThank you for using the BobDotCom.Biz ROI calculator, please visit BobDotCom.biz for more coroporate offerings"
   
   puts "Would you like to run the calculator again?"
   @decide = gets.chomp.downcase!
   if @decide == "yes"
   initialize
   end
end
  
end

m = LunchDex.new
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).