class WahWah::ID3::V2

Public Instance Methods

version() click to toggle source
# File lib/wahwah/id3/v2.rb, line 10
def version
  "v2.#{major_version}"
end

Private Instance Methods

end_of_tag?() click to toggle source
# File lib/wahwah/id3/v2.rb, line 52
def end_of_tag?
  size <= @file_io.pos || file_size <= @file_io.pos
end
parse() click to toggle source
# File lib/wahwah/id3/v2.rb, line 15
def parse
  @file_io.rewind
  @header = V2Header.new(@file_io)

  return unless valid?

  until end_of_tag? do
    frame = ID3::Frame.new(@file_io, major_version)
    (frame.skip; next) unless frame.valid?

    update_attribute(frame)
  end
end
parse_image_data(image_frame) click to toggle source
# File lib/wahwah/id3/v2.rb, line 56
def parse_image_data(image_frame)
  image_frame.value
end
update_attribute(frame) click to toggle source
# File lib/wahwah/id3/v2.rb, line 29
def update_attribute(frame)
  name = frame.name

  case name
  when :comment
    # Because there may be more than one comment frame in each tag,
    # so push it into a array.
    @comments.push(frame.value)
  when :image
    # Because there may be more than one image frame in each tag,
    # so push it into a array.
    @images_data.push(frame); frame.skip
  when :track, :disc
    # Track and disc value may be extended with a "/" character
    # and a numeric string containing the total numer.
    count, total_count = frame.value.split('/', 2)
    instance_variable_set("@#{name}", count)
    instance_variable_set("@#{name}_total", total_count) unless total_count.nil?
  else
    instance_variable_set("@#{name}", frame.value)
  end
end