Class: Fog::Brightbox::Compute::ImageSelector::NameSorter

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/brightbox/compute/image_selector.rb

Constant Summary collapse

PATTERN =
/\A(?<ubuntu>.*?)-(?<codename>.*?)-(?<version>[\d\.]*?)-(?<arch>.*?)/

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ NameSorter

Returns a new instance of NameSorter.



62
63
64
65
# File 'lib/fog/brightbox/compute/image_selector.rb', line 62

def initialize(name)
  @name = name
  @matches = name.match(PATTERN)
end

Instance Method Details

#archObject



67
68
69
# File 'lib/fog/brightbox/compute/image_selector.rb', line 67

def arch
  @matches[:arch] || ""
end

#codenameObject



71
72
73
# File 'lib/fog/brightbox/compute/image_selector.rb', line 71

def codename
  @matches[:codename] || ""
end

#ubuntu?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/fog/brightbox/compute/image_selector.rb', line 75

def ubuntu?
  @name.start_with?("ubuntu")
end

#versionObject



79
80
81
# File 'lib/fog/brightbox/compute/image_selector.rb', line 79

def version
  @matches[:version] || ""
end