-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got security quote import working okay
- Loading branch information
Showing
7 changed files
with
65 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
autoload :Net, "net/http" | |||
autoload :URI, "uri" | |||
|
|||
module Rupee | |||
# The quote and data import functionality in Rupee | |||
class Import | |||
class << self | |||
# Retrieves the current price of a security | |||
def quote(url, *options) | |||
url = URI.parse(url) | |||
res = Net::HTTP.start(url.host, url.port) do |http| | |||
http.get url.request_uri | |||
end | |||
puts res.body | |||
end | |||
|
|||
# Retrieves the current price of a security from Bloomberg | |||
def bloomberg(ticker, *options) | |||
quote BLOOMBERG_URL % ticker, options | |||
end | |||
|
|||
private | |||
|
|||
# The URL for Bloomberg's quotes service | |||
BLOOMBERG_URL = "http://www.bloomberg.com/apps/quote?ticker=%s" | |||
|
|||
# Returns an intepretation of an abbreviated source name | |||
def shorten_source(source) | |||
case source.downcase.to_sym | |||
when :"", :bloomberg, :bberg, :bb, :b | |||
:bloomberg | |||
when :google, :goog, :g | |||
when :yahoo!, :yahoo, :yhoo, :y!, :y | |||
:yahoo | |||
end | |||
end | |||
end | |||
end | |||
end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,4 @@ | |||
class Rupee | module Rupee | ||
# The current version | # The current version | ||
VERSION = "0.0.4" | VERSION = "0.0.5" | ||
end | end |