-
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.
- Loading branch information
Showing
3 changed files
with
67 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Rupee | ||
class Import | ||
# A class to hold quote sources | ||
class Source | ||
# The name of the source | ||
attr :name | ||
|
||
# The parameters available | ||
attr :params | ||
|
||
def initialize(name, aliases = [], params = {}) | ||
@name = name | ||
@aliases = aliases | ||
@params = params | ||
end | ||
end | ||
|
||
class << self | ||
# A holder for the sources available | ||
attr :sources | ||
|
||
# The default source to use when making generic requests | ||
attr :default_source | ||
|
||
# Build the default sources that come with Rupee | ||
def build_sources | ||
@sources ||= [] | ||
|
||
# Bloomberg | ||
@sources << Source.new(:bloomberg, [:bberg, :bb, :b], | ||
:price => /(?:PRICE|VALUE): <span class="amount">([0-9.,NA-]{1,})/, | ||
:change => /Change<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:pct_change => /Change<\/td>\n<td class="value[^>]+>[0-9.,NA-]{1,} \(([0-9NA.,-]{1,})\%/, | ||
:date => /"date">(.*?)</, | ||
:time => /"time">(.*?)</, | ||
:bid => /Bid<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:ask => /Ask<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:open => /Open<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:high => /High<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:low => /Low<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:volume => /Volume<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/, | ||
:mkt_cap => /Market Cap[^<]+<\/td>\n<td class="value">([0-9.,NA-]{1,})/, | ||
:p_e => /Price\/Earnings[^<]+<\/td>\n<td class="value">([0-9.,NA-]{1,})/) | ||
@sources << Source.new(:yahoo) | ||
@sources << Source.new(:google) | ||
@default_source = :bloomberg | ||
end | ||
end | ||
|
||
# Initialize sources | ||
Import.build_sources | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Rupee | ||
# The current version | ||
VERSION = "0.0.6" | ||
VERSION = "0.0.7" | ||
end |