Class: Bosh::Cli::PublicStemcell

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/public_stemcell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, size) ⇒ PublicStemcell

Returns a new instance of PublicStemcell.



5
6
7
8
9
10
# File 'lib/cli/public_stemcell.rb', line 5

def initialize(key, size)
  @key = key
  @size = size

  @parsed_version = key.scan(/[\d]*_?[\d]+/).first
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



3
4
5
# File 'lib/cli/public_stemcell.rb', line 3

def size
  @size
end

Instance Method Details

#legacy?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/cli/public_stemcell.rb', line 28

def legacy?
  @key.include?('legacy')
end

#nameObject



12
13
14
# File 'lib/cli/public_stemcell.rb', line 12

def name
  File.basename(@key)
end

#urlObject



24
25
26
# File 'lib/cli/public_stemcell.rb', line 24

def url
  "#{PublicStemcells::PUBLIC_STEMCELLS_BASE_URL}/#{@key}"
end

#varietyObject



20
21
22
# File 'lib/cli/public_stemcell.rb', line 20

def variety
  name.gsub(/(.tgz)|(bosh-stemcell-)|(#{@parsed_version})/, '').split('-').reject { |c| c.empty? }.join('-')
end

#versionObject



16
17
18
# File 'lib/cli/public_stemcell.rb', line 16

def version
  @parsed_version.gsub('_', '.').to_f
end