Very First Ruby Script

require ‘uri’
require ‘net/http’
require ‘tk’

@symbol =
@value =

def getvalue(s)
uri = URI.parse(“{s}”)
response = Net::HTTP.get_response(uri)
body = response.body
snip = body[body =~ /Last Trade/,70]
a = snip.split(//)

def searchvalue
@value.value = getvalue(@symbol.value)

pads = {‘padx’ => 10, ‘pady’ => 5}
root = {title “Stock”} {text “Enter stock symbol”; pack(pads)}, “textvariable” => @symbol).pack(pads), “textvariable” => @value).pack(pads)
search_b = {text “Search”; pack(pads)}
search_b.command {searchvalue}
exit_b = {text “Exit”; pack(pads)}
exit_b.command {exit}


Explore posts in the same categories: Uncategorized

One Comment on “Very First Ruby Script”

  1. Anonymous Says:

    nice stock ticker.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: