module SocialSnippet::Version
Public Class Methods
is_matched_version_pattern(pattern, version)
click to toggle source
Check given text matches version pattern
# 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" version.start_with?("#{pattern}.") end
is_version(s)
click to toggle source
Check given text is version string
# File lib/social_snippet/version.rb, line 20 def is_version(s) /^([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)$/ === s end
minor(s)
click to toggle source
“1.2.3” => “1.2”
# File lib/social_snippet/version.rb, line 25 def minor(s) /^(([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*))\.([0]|[1-9][0-9]*)$/.match(s)[1] end