Last active
October 6, 2015 22:58
-
-
Save douglasdollars/3066533 to your computer and use it in GitHub Desktop.
KMIKEYM current stock price and lowest offers available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# KMIKEYM current stock price and five lowest offers available | |
# By Douglas Dollars / @theDoug | |
require 'open-uri' | |
require 'nokogiri' | |
@page = Nokogiri::HTML(open("http://www.kmikeym.com/offers")) | |
@current_price = @page.xpath("//*[@id='price-block-inner']/h2/text()") | |
def offer(number) | |
who = slicer(number, "/td/a") | |
howmany = slicer(number, "/td[2]") | |
priced = slicer(number, "/td[3]") | |
return " #{who}: #{howmany} @ #{priced}" | |
end | |
def slicer(number, splud) | |
return @page.xpath("//*[@id='body']/div/div[5]/table/tr[#{number}]#{splud}/text()") | |
end | |
def line | |
puts '$------------------------------------------------------$' | |
end | |
def title_card(current_price) | |
puts ' | |
$$$ d$P $$$$$$$$$ $$$b d$$$ | |
$$$ d$P $$$ $$$$b d$$$$ S T O C K | |
$$$ d$P $$$ $$$$$b.d$$$$$ | |
$$$d$$K $$$$$$$b. $$$Y$$$$$P$$$ V A L U E | |
$$$$$$$b "Y$$b $$$ Y$$$P $$$ | |
$$$ Y$$b $$$ $$$ Y$P $$$ D I S P L A Y | |
$$$ Y$$b Y$$b d$$P $$$ " $$$ | |
$$$ Y$$b "Y$$$$P" $$$ $$$ T E R M I N A L' | |
line | |
puts " Current KmikeyM value: #{current_price}/share " | |
line | |
puts ' Lowest current offers (shares / price)' | |
line | |
end | |
def do_it | |
title_card(@current_price) | |
for i in 1..10 do puts offer(i) end | |
end | |
do_it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment