Class: FunWith::VersionStrings::VersionString
- Defined in:
- lib/version_strings/version_string.rb
Constant Summary collapse
- FORMAT_VALIDATOR =
/^(?:(?<major>\d+)\.?)?(?:(?<minor>\d+)\.?)?(?:(?<patch>\d+))?$/
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#patch ⇒ Object
(also: #tiny)
Returns the value of attribute patch.
Instance Method Summary collapse
-
#initialize(src) ⇒ VersionString
constructor
version must be of format n.nn or n.nn.nn.
Methods inherited from String
Constructor Details
#initialize(src) ⇒ VersionString
version must be of format n.nn or n.nn.nn
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/version_strings/version_string.rb', line 9 def initialize( src ) @match_data = src.match( FORMAT_VALIDATOR ) raise ArgumentError.new( "Not a valid version format for a VersionString." ) if @match_data.nil? @major = (@match_data[:major] || 0).to_i @minor = (@match_data[:minor] || 0).to_i @patch = (@match_data[:patch] || 0).to_i super( "#{@major}.#{@minor}.#{@patch}" ) end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
5 6 7 |
# File 'lib/version_strings/version_string.rb', line 5 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
5 6 7 |
# File 'lib/version_strings/version_string.rb', line 5 def minor @minor end |
#patch ⇒ Object Also known as: tiny
Returns the value of attribute patch.
5 6 7 |
# File 'lib/version_strings/version_string.rb', line 5 def patch @patch end |