Class: RD::Version
- Inherits:
-
Object
- Object
- RD::Version
- Defined in:
- lib/rd2odt/rdtool/rd/version.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#patch_level ⇒ Object
readonly
Returns the value of attribute patch_level.
Class Method Summary collapse
- .analyze_version_string(version_str) ⇒ Object
- .clean_up_version_string(version_str) ⇒ Object
- .new_from_version_string(name, version_str) ⇒ Object
Instance Method Summary collapse
-
#initialize(name, major, minor, patch_level) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(name, major, minor, patch_level) ⇒ Version
Returns a new instance of Version.
12 13 14 15 16 17 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 12 def initialize(name, major, minor, patch_level) @name = name @major = major @minor = minor @patch_level = patch_level end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
5 6 7 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 5 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
5 6 7 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 5 def minor @minor end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 4 def name @name end |
#patch_level ⇒ Object (readonly)
Returns the value of attribute patch_level.
5 6 7 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 5 def patch_level @patch_level end |
Class Method Details
.analyze_version_string(version_str) ⇒ Object
19 20 21 22 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 19 def Version.analyze_version_string(version_str) version_str = clean_up_version_string(version_str) version_str.split(/\./).collect{|i| i.to_i } end |
.clean_up_version_string(version_str) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 31 def Version.clean_up_version_string(version_str) if /^\$Version:?\s*(.*)\$/ === version_str $1 else version_str end end |
Instance Method Details
#to_s ⇒ Object
24 25 26 27 28 29 |
# File 'lib/rd2odt/rdtool/rd/version.rb', line 24 def to_s result = sprintf("%s %d", @name, @major) result += sprintf(".%d", @minor) if @minor result += sprintf(".%d", @patch_level) if @patch_level result end |