Class: OpenAPISourceTools::ApiObjects::ServerObject

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/openapi/sourcetools/apiobjects.rb

Overview

Single server object with variables.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject (readonly)

Returns the value of attribute url.



216
217
218
# File 'lib/openapi/sourcetools/apiobjects.rb', line 216

def url
  @url
end

#variablesObject (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