Class: Mp3file::XingHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/mp3file/xing_header.rb

Defined Under Namespace

Classes: XingHeaderFormat

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ XingHeader

Returns a new instance of XingHeader.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mp3file/xing_header.rb', line 25

def initialize(io)
  head = nil
  begin
    head = XingHeaderFormat.read(io)
  rescue BinData::ValidityError => ve
    raise InvalidXingHeaderError, ve.message
  end

  @name = head.vbr_id
  @frames = head.frames if (head.frames_present == 1 && head.frames > 0)
  @bytes = head.bytes if (head.bytes_present == 1 && head.bytes > 0)
  @toc = head.toc.dup if (head.toc_present == 1 && !head.toc.empty?)
  @quality = head.quality if (head.quality_present == 1 && head.quality > 0)
end

Instance Attribute Details

#bytesObject (readonly)

Returns the value of attribute bytes.



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

def bytes
  @bytes
end

#framesObject (readonly)

Returns the value of attribute frames.



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

def frames
  @frames
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#qualityObject (readonly)

Returns the value of attribute quality.



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

def quality
  @quality
end

#tocObject (readonly)

Returns the value of attribute toc.



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

def toc
  @toc
end