Class: D2L::Valence::Host
- Inherits:
-
Object
- Object
- D2L::Valence::Host
- Defined in:
- lib/d2l/valence/host.rb
Overview
Host
Class for the creation of URIs for communication with the D2L Valence API
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#initialize(scheme:, host:, port: nil) ⇒ Host
constructor
A new instance of Host.
- #to_uri(path: nil, query: nil) ⇒ Object
Constructor Details
#initialize(scheme:, host:, port: nil) ⇒ Host
Returns a new instance of Host.
11 12 13 14 15 |
# File 'lib/d2l/valence/host.rb', line 11 def initialize(scheme:, host:, port: nil) self.scheme = scheme self.host = host self.port = port end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/d2l/valence/host.rb', line 6 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/d2l/valence/host.rb', line 6 def port @port end |
#scheme ⇒ Object
Returns the value of attribute scheme.
6 7 8 |
# File 'lib/d2l/valence/host.rb', line 6 def scheme @scheme end |
Instance Method Details
#to_uri(path: nil, query: nil) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/d2l/valence/host.rb', line 29 def to_uri(path: nil, query: nil) { http: URI::HTTP.build(host: host, port: port, path: path, query: query), https: URI::HTTPS.build(host: host, port: port, path: path, query: query) }[scheme] end |