Module: ID3Lib::Frame
- Defined in:
- lib/id3lib.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.field(libframe, id) ⇒ Object
411 412 413 |
# File 'lib/id3lib.rb', line 411 def self.field(libframe, id) libframe.get_field(Info.field(id)[NUM]) end |
.read(libframe) ⇒ Object
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/id3lib.rb', line 349 def self.read(libframe) frame = {} info = Info.frame_num(libframe.get_id) frame[:id] = info[ID] info[FIELDS].each do |field_id| libfield = field(libframe, field_id) unless libfield warn "id3lib-ruby: Invalid field #{field_id.inspect} in " \ "#{frame[:id].inspect}, please report this as a bug." next end frame[field_id] = case Info::FieldType[libfield.get_type] when :integer libfield.get_integer when :binary libfield.get_binary when :text if libfield.get_encoding > 0 libfield.get_unicode else libfield.get_ascii end end end frame end |
.write(frame, libframe) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'lib/id3lib.rb', line 379 def self.write(frame, libframe) if textenc = frame[:textenc] field(libframe, :textenc).set_integer(textenc) end frame.each do |field_id, value| next if field_id == :textenc unless Info.frame(frame[:id])[FIELDS].include?(field_id) # Ignore invalid fields next end libfield = field(libframe, field_id) next unless libfield case Info::FieldType[libfield.get_type] when :integer libfield.set_integer(value) when :binary libfield.set_binary(value) when :text if textenc and textenc > 0 and [:text, :description, :filename].include?(field_id) # Special treatment for Unicode libfield.set_encoding(textenc) libfield.set_unicode(value) else libfield.set_ascii(value) end end end end |