Class: Mp3file::ID3v2::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/mp3file/id3v2/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vmaj, vmin, vbig = 2) ⇒ Version

Returns a new instance of Version.



7
8
9
10
11
# File 'lib/mp3file/id3v2/version.rb', line 7

def initialize(vmaj, vmin, vbig = 2)
  @vbig = vbig.to_i
  @vmaj = vmaj.to_i
  @vmin = vmin.to_i
end

Instance Attribute Details

#vbigObject (readonly)

Returns the value of attribute vbig.



5
6
7
# File 'lib/mp3file/id3v2/version.rb', line 5

def vbig
  @vbig
end

#vmajObject (readonly)

Returns the value of attribute vmaj.



5
6
7
# File 'lib/mp3file/id3v2/version.rb', line 5

def vmaj
  @vmaj
end

#vminObject (readonly)

Returns the value of attribute vmin.



5
6
7
# File 'lib/mp3file/id3v2/version.rb', line 5

def vmin
  @vmin
end

Instance Method Details

#<=>(other) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/mp3file/id3v2/version.rb', line 13

def <=>(other)
  c = vbig <=> other.vbig
  return c if c != 0

  c = vmaj <=> other.vmaj
  return c if c != 0

  vmin <=> other.vmin
end

#inspectObject



31
32
33
34
# File 'lib/mp3file/id3v2/version.rb', line 31

def inspect
  "<%p vbig = %p vmaj = %p vmin = %p>" %
    [ self.class, @vbig, @vmaj, @vmin ]
end

#to_byte_stringObject



27
28
29
# File 'lib/mp3file/id3v2/version.rb', line 27

def to_byte_string
  [ vmaj, vmin ].pack("cc")
end

#to_sObject



23
24
25
# File 'lib/mp3file/id3v2/version.rb', line 23

def to_s
  "ID3v%d.%d.%d" % [ vbig, vmaj, vmin ]
end