Class: CommandBuilder::CodeGenerator::Version
- Inherits:
-
Object
- Object
- CommandBuilder::CodeGenerator::Version
- Defined in:
- lib/command_builder/code_generator/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.
8 9 10 |
# File 'lib/command_builder/code_generator/version.rb', line 8 def version @version end |
Class Method Details
.match(value) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/command_builder/code_generator/version.rb', line 31 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
15 16 17 |
# File 'lib/command_builder/code_generator/version.rb', line 15 def compact first 2, '' end |
#first(count, delimiter = DELIMITER) ⇒ Object
19 20 21 |
# File 'lib/command_builder/code_generator/version.rb', line 19 def first(count, delimiter=DELIMITER) to_a.first(count).join(delimiter) end |
#to_a ⇒ Object
27 28 29 |
# File 'lib/command_builder/code_generator/version.rb', line 27 def to_a @version.split DELIMITER end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/command_builder/code_generator/version.rb', line 23 def to_s @version end |