Class: ThatLanguage::Client
- Inherits:
-
Object
- Object
- ThatLanguage::Client
- Defined in:
- lib/that_language/client.rb,
lib/that_language/client/query.rb,
lib/that_language/client/config.rb,
lib/that_language/client/version.rb,
lib/that_language/client/detect_query.rb,
lib/that_language/client/details_query.rb,
lib/that_language/client/version_query.rb,
lib/that_language/client/language_query.rb,
lib/that_language/client/available_query.rb,
lib/that_language/client/language_code_query.rb
Defined Under Namespace
Classes: AvailableQuery, Config, DetailsQuery, DetectQuery, LanguageCodeQuery, LanguageQuery, Query, VersionQuery
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Class Method Summary collapse
Instance Method Summary collapse
-
#base_url ⇒ Object
hostmay be a bare "example.com", a "host:port", or a full base URL carrying a scheme. -
#initialize(host:) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(host:) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/that_language/client.rb', line 17 def initialize(host:) @host = host end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
15 16 17 |
# File 'lib/that_language/client.rb', line 15 def host @host end |
Class Method Details
.config ⇒ Object
35 36 37 |
# File 'lib/that_language/client.rb', line 35 def self.config @config ||= Config.new end |
.configure {|config| ... } ⇒ Object
39 40 41 |
# File 'lib/that_language/client.rb', line 39 def self.configure yield(config) end |
Instance Method Details
#base_url ⇒ Object
host may be a bare "example.com", a "host:port", or a full base URL
carrying a scheme. Anything without a scheme is assumed to be http, which
is what this client always did; https is now expressible, and any real
deployment will need it.
25 26 27 28 29 |
# File 'lib/that_language/client.rb', line 25 def base_url return host.sub(%r{/+\z}, "") if host.include?("://") "http://#{host}" end |