Module: SocialSnippet::RegistryCore::VersionHelpers
- Defined in:
- lib/social_snippet/registry_core/version_helpers.rb
Class Method Summary collapse
-
.is_version?(s) ⇒ Boolean
Check given text is version string.
-
.test_version(pattern, version) ⇒ Object
Check given text whether matches version pattern.
Class Method Details
.is_version?(s) ⇒ Boolean
Check given text is version string
15 16 17 |
# File 'lib/social_snippet/registry_core/version_helpers.rb', line 15 def is_version?(s) return /^([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)$/ === s end |
.test_version(pattern, version) ⇒ Object
Check given text whether matches version pattern
6 7 8 9 10 11 12 |
# File 'lib/social_snippet/registry_core/version_helpers.rb', line 6 def test_version(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 |