Class: Misty::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/misty/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Service

Returns a new instance of Service.



5
6
7
8
9
10
# File 'lib/misty/service.rb', line 5

def initialize(params)
  @type = params[:type]
  @project = params[:project]
  @versions = params[:versions]
  @microversion = params[:microversion]
end

Instance Attribute Details

#microversionObject (readonly)

Returns the value of attribute microversion.



3
4
5
# File 'lib/misty/service.rb', line 3

def microversion
  @microversion
end

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/misty/service.rb', line 3

def project
  @project
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/misty/service.rb', line 3

def type
  @type
end

#versionsObject (readonly)

Returns the value of attribute versions.



3
4
5
# File 'lib/misty/service.rb', line 3

def versions
  @versions
end

Instance Method Details

#default_version(api_version = nil) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/misty/service.rb', line 19

def default_version(api_version = nil)
  res = if api_version && (@versions&.include?(api_version))
          api_version
        else
          self.versions.sort[-1]
        end
  res
end

#to_sObject



12
13
14
15
16
17
# File 'lib/misty/service.rb', line 12

def to_s
  str = "#{type}: #{project}"
  str << ", versions: #{@versions}" if @versions
  str << ", microversion: #{@microversion}" if @microversion
  str
end