Skip to content
Newer
Older
100644 65 lines (45 sloc) 2.3 KB
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
1 = YahooCurrency
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
2
b87a487 @scottjbarr Updated gem description
scottjbarr authored Feb 11, 2009
3 Retrieve currency exchange rates from Yahoo! Finance.
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
4
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
5 == The Yahoo! Finance Service
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
6
7 URL to fetch the AUD to USD exchange rate
8
9 http://download.finance.yahoo.com/d/quotes.csv?s=AUDUSD=X&f=nl1d1t1
10
11 Although the Yahoo! service supports multiple rates values from one request,
12 this class does not yet support this functionality yet.
13
14 $ curl "http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X+JPYUSD=X+GBPUSD=X+USDJPY=X+EURUSD=X&f=nl1d1t1"
15 "USD to CAD",1.0191,"6/18/2008","2:45am"
16 "JPY to USD",0.0093,"6/18/2008","2:45am"
17 "GBP to USD",1.9514,"6/18/2008","2:44am"
18 "USD to JPY",108.085,"6/18/2008","2:45am"
19 "EUR to USD",1.5493,"6/18/2008","2:44am"
20
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
21 == Features
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
22
23 * So easy to use, even a baby could find out what his currency is trading at.
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
24 * Tested with Ruby 1.8.7 and 1.9.1
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
25
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
26 == Example
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
27
28 exchange_rate = YahooCurrency.get_rate!("JPY", "USD")
29 exchange_rate.from #=> "JPY"
30 exchange_rate.to #=> "USD"
31 exchange_rate.rate #=> 0.0111
32 exchange_rate.timestamp #=> Wed Feb 11 22:20:00 +0800 2009
33
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
34 == References
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
35
36 * http://gummy-stuff.org/forex.htm
37 * http://www.thinkruby.org/tags/currency-converter
38 * http://finance.yahoo.com/currency
919d896 @scottjbarr Tidied up References in README.rdoc
scottjbarr authored Feb 11, 2009
39 * http://gummy-stuff.org/Yahoo-data.htm
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
40
2e83f39 @scottjbarr Updated to run under Ruby 1.8 and 1.9
scottjbarr authored Mar 7, 2009
41 == License
40f92ec @scottjbarr Clarified the License in README.rdoc
scottjbarr authored Feb 11, 2009
42
43 (The MIT License)
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
44
154e050 @scottjbarr Fixed GITC name in README.rdoc
scottjbarr authored Feb 11, 2009
45 Copyright (c) 2009 Global IT Creations Pte Ltd http://www.globalitcreations.com
90729ab @scottjbarr Initial commit
scottjbarr authored Feb 11, 2009
46
47 Permission is hereby granted, free of charge, to any person obtaining a copy
48 of this software and associated documentation files (the "Software"), to deal
49 in the Software without restriction, including without limitation the rights
50 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51 copies of the Software, and to permit persons to whom the Software is
52 furnished to do so, subject to the following conditions:
53
54 The above copyright notice and this permission notice shall be included in
55 all copies or substantial portions of the Software.
56
57 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
63 THE SOFTWARE.
64
Something went wrong with that request. Please try again.