Module: K2ConnectRuby::K2Utilities::Config::K2Config
- Defined in:
- lib/k2-connect-ruby/k2_utilities/config/k2_config.rb
Class Method Summary collapse
- .base_url ⇒ Object
-
.base_url=(base_url) ⇒ Object
Set the Host Url.
- .endpoint(key) ⇒ Object
- .endpoints ⇒ Object
- .network_operators ⇒ Object
- .path(key) ⇒ Object
Class Method Details
.base_url ⇒ Object
20 21 22 |
# File 'lib/k2-connect-ruby/k2_utilities/config/k2_config.rb', line 20 def base_url @config[:base_url] end |
.base_url=(base_url) ⇒ Object
Set the Host Url
13 14 15 16 17 18 |
# File 'lib/k2-connect-ruby/k2_utilities/config/k2_config.rb', line 13 def base_url=(base_url) raise(ArgumentError, "Invalid URL Format.") unless base_url =~ /\A#{URI.regexp(["http", "https"])}\z/ @config[:base_url] = base_url File.open(File.join(File.dirname(__FILE__), "k2_config.yml"), "w") { |f| YAML.dump(@config, f) } end |
.endpoint(key) ⇒ Object
28 29 30 |
# File 'lib/k2-connect-ruby/k2_utilities/config/k2_config.rb', line 28 def endpoint(key) base_url + path(key) end |
.endpoints ⇒ Object
24 25 26 |
# File 'lib/k2-connect-ruby/k2_utilities/config/k2_config.rb', line 24 def endpoints @config[:endpoints] end |
.network_operators ⇒ Object
38 39 40 |
# File 'lib/k2-connect-ruby/k2_utilities/config/k2_config.rb', line 38 def network_operators @config[:network_operators] end |
.path(key) ⇒ Object
32 33 34 35 36 |
# File 'lib/k2-connect-ruby/k2_utilities/config/k2_config.rb', line 32 def path(key) return @config[:endpoints][:"#{key}"].to_s unless key.include?("token") @config[:endpoints][:"#{key}"] end |