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

#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

#version(api_version = nil) ⇒ Object



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

def version(api_version = nil)
  if api_version
    return api_version if (@versions && @versions.include?(api_version)) || @microversion == api_version
  end
  default_version
end