Class: OpenAPISourceTools::ApiObjects::ServerObject
- Inherits:
-
Object
- Object
- OpenAPISourceTools::ApiObjects::ServerObject
- Includes:
- Comparable
- Defined in:
- lib/openapi/sourcetools/apiobjects.rb
Overview
Single server object with variables.
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(server_object) ⇒ ServerObject
constructor
A new instance of ServerObject.
Constructor Details
#initialize(server_object) ⇒ ServerObject
Returns a new instance of ServerObject.
218 219 220 221 222 223 224 225 |
# File 'lib/openapi/sourcetools/apiobjects.rb', line 218 def initialize(server_object) @url = server_object['url'] vs = server_object['variables'] || {} @variables = vs.keys.sort!.map do |name| obj = vs[name] ServerVariableObject.new(name, obj) end end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
216 217 218 |
# File 'lib/openapi/sourcetools/apiobjects.rb', line 216 def url @url end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
216 217 218 |
# File 'lib/openapi/sourcetools/apiobjects.rb', line 216 def variables @variables end |
Instance Method Details
#<=>(other) ⇒ Object
227 228 229 230 231 232 233 234 235 |
# File 'lib/openapi/sourcetools/apiobjects.rb', line 227 def <=>(other) d = @url <=> other.url return d unless d.zero? if @variables.nil? || other.variables.nil? return -1 if @variables.nil? return 1 if other.variables.nil? end @variables <=> other.variables end |