Class: TripSpark::Configuration
- Inherits:
-
Object
- Object
- TripSpark::Configuration
- Defined in:
- lib/tripspark_api/configuration.rb
Constant Summary collapse
- DEFAULT_CONFIGURATION =
The defaults to use for any configuration options that are not provided
{ version: '3.2', # Taken from a comment on "http://bus.gocitybus.com/RouteMap/Index" adapter: :httparty, debug_output: false }
- REQUIRED_CONFIGURATION =
The options required when configuring a TripSpark instance
[ :base_uri ]
Instance Attribute Summary collapse
-
#adapter ⇒ Object
The adapter to use for network communication.
-
#base_uri ⇒ Object
The base URL of the TripSpark system.
-
#debug_output ⇒ Object
The output stream to which debug information should be written.
-
#version ⇒ Object
The version of the TripSpark system.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#validate! ⇒ Object
Ensure that all required configurations have been given a value.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 30 |
# File 'lib/tripspark_api/configuration.rb', line 24 def initialize # Apply the default set of configurations before anything else to ensure # all options are initialized. DEFAULT_CONFIGURATION.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#adapter ⇒ Object
The adapter to use for network communication
8 9 10 |
# File 'lib/tripspark_api/configuration.rb', line 8 def adapter @adapter end |
#base_uri ⇒ Object
The base URL of the TripSpark system
6 7 8 |
# File 'lib/tripspark_api/configuration.rb', line 6 def base_uri @base_uri end |
#debug_output ⇒ Object
The output stream to which debug information should be written
10 11 12 |
# File 'lib/tripspark_api/configuration.rb', line 10 def debug_output @debug_output end |
#version ⇒ Object
The version of the TripSpark system
4 5 6 |
# File 'lib/tripspark_api/configuration.rb', line 4 def version @version end |
Instance Method Details
#validate! ⇒ Object
Ensure that all required configurations have been given a value. Returns true if all required configuration options have been set.
34 35 36 37 38 39 |
# File 'lib/tripspark_api/configuration.rb', line 34 def validate! REQUIRED_CONFIGURATION.each do |name| raise "`#{name}` is a required configuration option, but was not given a value." if send("#{name}").nil? end true end |