Module: SocialSnippet::Version

Defined in:
lib/social_snippet/version.rb

Class Method Summary collapse

Class Method Details

.is_matched_version_pattern(pattern, version) ⇒ Object

Check given text matches version pattern


10
11
12
13
14
15
16
17
# File 'lib/social_snippet/version.rb', line 10

def is_matched_version_pattern(pattern, version)
  return true if pattern == "" || pattern.nil?
  return true if pattern == version

  # "2.1.0" and "2.1.1" match "2.1"
  # "2.11.0" and "2.11.1" do not match "2.1"
  return version.start_with?("#{pattern}.")
end

.is_version(s) ⇒ Object

Check given text is version string


20
21
22
# File 'lib/social_snippet/version.rb', line 20

def is_version(s)
  return /^([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)$/ === s
end