Class: AgentOrange::Version
- Inherits:
-
Object
- Object
- AgentOrange::Version
- Defined in:
- lib/agent_orange/version.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(version_string) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ String
Constructor Details
#initialize(version_string) ⇒ Version
Returns a new instance of Version.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/agent_orange/version.rb', line 17 def initialize(version_string) version_string = sanitize_version_string(version_string) self.major = nil self.minor = nil self.patch_level = nil self.build_number = nil pieces = version_string.split('.') pieces_count = pieces.count self.major = pieces[0] if pieces_count >= 1 self.minor = pieces[1] if pieces_count >= 2 self.patch_level = pieces[2] if pieces_count >= 3 self.build_number = pieces[3] if pieces_count >= 4 end |
Instance Attribute Details
#build_number ⇒ String?
15 16 17 |
# File 'lib/agent_orange/version.rb', line 15 def build_number @build_number end |
#major ⇒ String?
6 7 8 |
# File 'lib/agent_orange/version.rb', line 6 def major @major end |
#minor ⇒ String?
9 10 11 |
# File 'lib/agent_orange/version.rb', line 9 def minor @minor end |
#patch_level ⇒ String?
12 13 14 |
# File 'lib/agent_orange/version.rb', line 12 def patch_level @patch_level end |
Instance Method Details
#to_s ⇒ String
34 35 36 |
# File 'lib/agent_orange/version.rb', line 34 def to_s [major, minor, patch_level, build_number].compact.join('.') end |