Class: NJTransit::Configuration
- Inherits:
-
Object
- Object
- NJTransit::Configuration
- Defined in:
- lib/njtransit/configuration.rb
Constant Summary collapse
- VALID_LOG_LEVELS =
%w[silent info debug].freeze
- DEFAULT_BASE_URL =
"https://pcsdata.njtransit.com"- DEFAULT_RAIL_BASE_URL =
"https://raildata.njtransit.com"- DEFAULT_TIMEOUT =
30
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#gtfs_database_path ⇒ Object
Returns the value of attribute gtfs_database_path.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#password ⇒ Object
Returns the value of attribute password.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 19 20 |
# File 'lib/njtransit/configuration.rb', line 13 def initialize @username = ENV.fetch("NJTRANSIT_USERNAME", nil) @password = ENV.fetch("NJTRANSIT_PASSWORD", nil) @log_level = ENV.fetch("NJTRANSIT_LOG_LEVEL", "silent") @base_url = ENV.fetch("NJTRANSIT_BASE_URL", DEFAULT_BASE_URL) @timeout = ENV.fetch("NJTRANSIT_TIMEOUT", DEFAULT_TIMEOUT).to_i @gtfs_database_path = ENV.fetch("NJTRANSIT_GTFS_DATABASE_PATH", nil) || default_gtfs_database_path end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
10 11 12 |
# File 'lib/njtransit/configuration.rb', line 10 def base_url @base_url end |
#gtfs_database_path ⇒ Object
Returns the value of attribute gtfs_database_path.
10 11 12 |
# File 'lib/njtransit/configuration.rb', line 10 def gtfs_database_path @gtfs_database_path end |
#log_level ⇒ Object
Returns the value of attribute log_level.
11 12 13 |
# File 'lib/njtransit/configuration.rb', line 11 def log_level @log_level end |
#password ⇒ Object
Returns the value of attribute password.
10 11 12 |
# File 'lib/njtransit/configuration.rb', line 10 def password @password end |
#timeout ⇒ Object
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/njtransit/configuration.rb', line 10 def timeout @timeout end |
#username ⇒ Object
Returns the value of attribute username.
10 11 12 |
# File 'lib/njtransit/configuration.rb', line 10 def username @username end |
Instance Method Details
#to_h ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/njtransit/configuration.rb', line 32 def to_h { username: username, password: password, log_level: log_level, base_url: base_url, timeout: timeout } end |