Class: Debian::Versions::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/msp_release/debian.rb

Direct Known Subclasses

Development, Stable, Unrecognized, Unreleased

Class Method Summary collapse

Class Method Details

.new_from_string(string) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/msp_release/debian.rb', line 17

def self.new_from_string(string)
  match = pattern.match(string)
  parts = (1...match.length).map {|idx| match[idx] }
  begin
    new(*parts)
  rescue => e
    raise "Unable to construct #{self} from #{string}\n#{e.to_s}"
  end
end

.new_if_matches(string) ⇒ Object



13
14
15
# File 'lib/msp_release/debian.rb', line 13

def self.new_if_matches(string)
  pattern.match(string) && new_from_string(string)
end