Class: OFX::Version
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #empty? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #major ⇒ Object
- #minor ⇒ Object
- #revision ⇒ Object
- #to_a ⇒ Object
- #to_compact_s ⇒ Object
- #to_dotted_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ofx/version.rb', line 22 def initialize(version) @version = [0, 0, 0] return if version.nil? parts = case version when Version version.to_a when Integer [version, 0, 0] when Array version when /\./ version.split(".") else [version[0..0], version[1..1], version[2..2]] end @version[0] = parts[0].to_i @version[1] = parts[1].to_i @version[2] = parts[2].to_i end |
Instance Method Details
#<=>(other) ⇒ Object
72 73 74 |
# File 'lib/ofx/version.rb', line 72 def <=> (other) @version <=> other.to_a end |
#empty? ⇒ Boolean
68 69 70 |
# File 'lib/ofx/version.rb', line 68 def empty? @version == [0, 0, 0] end |
#eql?(other) ⇒ Boolean
75 76 77 78 79 |
# File 'lib/ofx/version.rb', line 75 def eql?(other) other_a = other.to_a return @version[0] == other_a[0] && @version[1] == other_a[1] && @version[2] == other_a[2] end |
#hash ⇒ Object
80 81 82 |
# File 'lib/ofx/version.rb', line 80 def hash() return @version.hash end |
#major ⇒ Object
45 46 47 |
# File 'lib/ofx/version.rb', line 45 def major @version[0] end |
#minor ⇒ Object
49 50 51 |
# File 'lib/ofx/version.rb', line 49 def minor @version[1] end |
#revision ⇒ Object
53 54 55 |
# File 'lib/ofx/version.rb', line 53 def revision @version[2] end |
#to_a ⇒ Object
64 65 66 |
# File 'lib/ofx/version.rb', line 64 def to_a @version.dup end |
#to_compact_s ⇒ Object
60 61 62 |
# File 'lib/ofx/version.rb', line 60 def to_compact_s @version.join('') end |
#to_dotted_s ⇒ Object
57 58 59 |
# File 'lib/ofx/version.rb', line 57 def to_dotted_s @version.join('.') end |