lbank 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Gemfile +2 -0
  2. data/lib/lbank/version.rb +1 -1
  3. data/lib/lbank.rb +8 -3
  4. metadata +1 -1
data/Gemfile CHANGED
@@ -3,6 +3,8 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'rake'
6
+ gem 'tzinfo'
7
+ gem 'activesupport'
6
8
 
7
9
  group :test do
8
10
  gem "rspec"
data/lib/lbank/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lbank
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/lbank.rb CHANGED
@@ -1,18 +1,23 @@
1
1
  require "lbank/version"
2
2
  require 'open-uri'
3
3
  require 'csv'
4
+ require 'active_support/time'
4
5
 
5
6
  module Lbank
6
7
 
7
8
  BASE_CURRENCY = 'LTL'
9
+ TIMEZONE = 'Europe/Vilnius'
8
10
  SOURCE = 'http://lbank.lt/exchange/Results.asp'
11
+
9
12
  @@cache = {}
10
13
 
11
- def self.currency_rates(date = nil)
12
- date ||= Date.today
14
+ def self.currency_rates(time = nil)
15
+ time ||= Time.now
16
+ bank_time = time.to_time.in_time_zone(TIMEZONE)
17
+ date = [ bank_time.year, bank_time.month, bank_time.day ]
13
18
 
14
19
  if @@cache[date].nil?
15
- url = "#{SOURCE}?Y=%i&M=%i&D=%i&S=csv" % [ date.year, date.month, date.day ]
20
+ url = "#{SOURCE}?Y=%i&M=%i&D=%i&S=csv" % date
16
21
  rates = {}
17
22
 
18
23
  data = open(url).read
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: