Module: OXR
- Defined in:
- lib/oxr.rb,
lib/oxr/version.rb,
lib/oxr/configuration.rb
Defined Under Namespace
Classes: ApiError, Configuration, Error
Constant Summary
collapse
- VERSION =
"0.4.0"
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
74
75
76
|
# File 'lib/oxr.rb', line 74
def configuration
@configuration ||= Configuration.new
end
|
69
70
71
72
|
# File 'lib/oxr.rb', line 69
def configure
yield configuration if block_given?
configuration
end
|
.currencies ⇒ Object
47
48
49
|
# File 'lib/oxr.rb', line 47
def currencies
call configuration.currencies
end
|
.get_rate(code, on: nil) ⇒ Object
Also known as:
[]
36
37
38
39
40
41
42
43
|
# File 'lib/oxr.rb', line 36
def get_rate(code, on: nil)
data = if on
historical on: on
else
latest
end
data['rates'][code.to_s]
end
|
.historical(on:) ⇒ Object
51
52
53
|
# File 'lib/oxr.rb', line 51
def historical(on:)
call configuration.historical on
end
|
.latest ⇒ Object
55
56
57
|
# File 'lib/oxr.rb', line 55
def latest
call configuration.latest
end
|
.new(app_id) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/oxr.rb', line 27
def new(app_id)
warn '[DEPRECATION WARNING] OXR.new is depr4ecated.' \
" Use OXR class methods instead (from #{caller.first})."
configure do |config|
config.app_id = app_id
end
self
end
|
.reset_sources ⇒ Object
63
64
65
66
67
|
# File 'lib/oxr.rb', line 63
def reset_sources
configure do |config|
config.reset_sources
end
end
|
.usage ⇒ Object
59
60
61
|
# File 'lib/oxr.rb', line 59
def usage
call configuration.usage
end
|