File: libvirt.rb

package info (click to toggle)
ruby-libvirt 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 832 kB
  • sloc: ansic: 8,052; ruby: 2,541; makefile: 6
file content (40 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
# libvirt.rb: main module for the ruby-libvirt bindings
#
# Copyright (C) 2007 Red Hat, Inc.
#
# Distributed under the GNU Lesser General Public License v2.1 or later.
# See COPYING for details
#
# David Lutterkort <dlutter@redhat.com>

require '_libvirt'

module Libvirt

    # A version in Libvirt's representation
    class Version
        attr_reader :version, :type

        def initialize(type, version)
            @type = type
            @version = version
        end

        def major
            version / 1000000
        end

        def minor
            version % 1000000 / 1000
        end

        def release
            version % 1000
        end

        def to_s
            "#{major}.#{minor}.#{release}"
        end
    end
end