Class: Kibosh::Session::Version
- Inherits:
-
Object
- Object
- Kibosh::Session::Version
- Includes:
- Comparable
- Defined in:
- lib/kibosh/session.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(ver) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(ver) ⇒ Version
Returns a new instance of Version.
21 22 23 24 25 |
# File 'lib/kibosh/session.rb', line 21 def initialize ver m = %r{^(\d+).(\d+)$}.match ver raise BadRequest.new nil, "Bad version format: #{ver}" if !m @major, @minor = m[1].to_i, m[2].to_i end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
20 21 22 |
# File 'lib/kibosh/session.rb', line 20 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
20 21 22 |
# File 'lib/kibosh/session.rb', line 20 def minor @minor end |
Instance Method Details
#<=>(other) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/kibosh/session.rb', line 26 def <=> other diff = @major - other.major if diff == 0 diff = @minor - other.minor end diff end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/kibosh/session.rb', line 33 def to_s "#{@major}.#{@minor}" end |