Class: Version
- Inherits:
-
Object
- Object
- Version
- Defined in:
- lib/getversion/version.rb
Constant Summary collapse
- VERSION_REGEX =
'(?:\d+\.)+(?:\d+)'- DELIMITER =
'.'
Instance Attribute Summary collapse
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #compact ⇒ Object
- #first(count, delimiter = DELIMITER) ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/getversion/version.rb', line 6 def version @version end |
Class Method Details
.match(value) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/getversion/version.rb', line 29 def self.match(value) exp = Regexp.new VERSION_REGEX version = value.scan(exp)[0] return unless version Version.new(version) end |
Instance Method Details
#compact ⇒ Object
13 14 15 |
# File 'lib/getversion/version.rb', line 13 def compact first 2, '' end |
#first(count, delimiter = DELIMITER) ⇒ Object
17 18 19 |
# File 'lib/getversion/version.rb', line 17 def first(count, delimiter=DELIMITER) to_a.first(count).join(delimiter) end |
#to_a ⇒ Object
25 26 27 |
# File 'lib/getversion/version.rb', line 25 def to_a @version.split DELIMITER end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/getversion/version.rb', line 21 def to_s @version end |