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)
  @name = params[:name]
  @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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
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
27
28
# File 'lib/misty/service.rb', line 19

def default_version(api_version = nil)
  res = if api_version && (@versions&.include?(api_version) || api_version == @microversion)
          api_version
        elsif @microversion
          @microversion
        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 = "#{name}: #{project}"
  str << ", versions: #{@versions}" if @versions
  str << ", microversion: #{@microversion}" if @microversion
  str
end