Class: Ogg::Vorbis::CommentHeaderPacket

Inherits:
HeaderPacket show all
Defined in:
lib/ogginfo-rb.rb

Overview

Instance Attribute Summary collapse

Attributes inherited from HeaderPacket

#packet_type

Attributes inherited from Packet

#data

Instance Method Summary collapse

Methods inherited from Packet

#next_page

Constructor Details

#initialize(page) ⇒ CommentHeaderPacket

Returns a new instance of CommentHeaderPacket.



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/ogginfo-rb.rb', line 204

def initialize page
  super

  vendor_length = @data.read(4).unpack('L').first
  @vendor_string = @data.read(vendor_length)
  user_comment_list_length = @data.read(4).unpack('L').first
  @comments = {}

  user_comment_list_length.times do
    length = @data.read(4).unpack('L').first
    comment = @data.read(length)
    key, value = comment.split('=', 2)
    (@comments[key.upcase] ||= []) << value
  end
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



202
203
204
# File 'lib/ogginfo-rb.rb', line 202

def comments
  @comments
end

#vendor_stringObject (readonly)

Returns the value of attribute vendor_string.



202
203
204
# File 'lib/ogginfo-rb.rb', line 202

def vendor_string
  @vendor_string
end