ExchangeRateVlad 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ExchangeRate.rb +20 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: db5f5a7ffe6ea0bafd69a3e1b5016fb1845436b7
|
|
4
|
+
data.tar.gz: 4c82e20657cd07fd059edb79c72b5285cac9b50d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1ca5de09da13c4b29995578357682cb39e3fcc153ddfeba2349e0218b834a9271970aafadf25298862e90d21e900ddbedb57fea8670cdb437b58fcec47d8a6c7
|
|
7
|
+
data.tar.gz: 23068d1ee1bfb87dc33a1e713d547f60446069988ec440ac5d339b659465d7327b800452ce58e22134850e49ee7f92fe8ce056defca92162b83ab7df11b18af2
|
data/lib/ExchangeRate.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Converter
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
@@doc
|
|
4
|
+
def init(file)
|
|
5
|
+
f = File.open(file)
|
|
6
|
+
@@doc = Nokogiri::XML(f)
|
|
7
|
+
f.close
|
|
8
|
+
end
|
|
9
|
+
def at(date, c1, c2)
|
|
10
|
+
d = date.strftime("%Y-%m-%d")
|
|
11
|
+
r = @@doc.css('Cube Cube[@time="'+d+'"]')
|
|
12
|
+
er1 = r.at_css('[@currency="'+c1+'"]')['rate'].to_f
|
|
13
|
+
er2 = r.at_css('[@currency="'+c2+'"]')['rate'].to_f
|
|
14
|
+
return er2/er1
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
require 'date'
|
|
19
|
+
|
|
20
|
+
ExchangeRate = Converter.new
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ExchangeRateVlad
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vlad Otrocol
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2010-04-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A gem for FreeAgent
|
|
14
|
+
email: vladotrocol@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/ExchangeRate.rb
|
|
20
|
+
homepage: http://rubygems.org/gems/ExchangeRateVlad
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.2.3
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Currency exchange rate
|
|
44
|
+
test_files: []
|