Class XSPF::Track
In: xspf-expanded.rb
lib/xspf.rb
Parent: Object

Methods

Attributes

track  [R] 

Public Class methods

Creates a XSPF::Track object from a <track> section of the XSPF document or from a hash of values

Possible keys in the hash in generation mode: :location, :identifier, :title, :creator, :annotation, :info, :image, :album, :tracknum, :duration, :extension, :link_rel, :link_content, :meta_rel, :meta_content)

[Source]

     # File lib/xspf.rb, line 415
415:   def initialize(tr)
416:     
417:     if tr.instance_of?(Hash)
418: 
419:       ELEMENTS.each do |element|
420:         add_instance_variable(tr, element.downcase)
421:       end
422: 
423:       ATTRIBUTE_AND_ELEMENT.each do |ae|
424:         add_instance_variable(tr, "#{ae.downcase}_content" )
425:         add_instance_variable(tr, "#{ae.downcase}_rel" )
426:       end
427:       
428:     else
429:       @track = tr
430: 
431:       ELEMENTS.each do |element|
432:         eval('@' + element.downcase + '= parse_' + element.downcase)
433:       end
434: 
435:       ATTRIBUTE_AND_ELEMENT.each do |ae|
436:         eval('@' + ae.downcase + '_content = parse_' + ae.downcase + '_content')
437:         eval('@' + ae.downcase + '_rel = parse_' + ae.downcase + '_rel')
438:       end
439:     end
440:     
441:   end

Public Instance methods

Human-readable name of the collection from which the resource which defines the duration of track rendering comes. For a song originally published as a part of a CD or LP, this would be the title of the original release. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one.

[Source]

     # File xspf-expanded.rb, line 563
563:     def album
564:       @album
565:     end

[Source]

     # File xspf-expanded.rb, line 567
567:     def album=(value)
568:       @album = value
569:     end

A human-readable comment on the track. This is character data, not HTML, and it may not contain markup. XSPF::Track objects MAY contain exactly one.

[Source]

     # File xspf-expanded.rb, line 503
503:     def annotation
504:       @annotation
505:     end

[Source]

     # File xspf-expanded.rb, line 507
507:     def annotation=(value)
508:       @annotation = value
509:     end

Human-readable name of the entity (author, authors, group, company, etc) that authored the resource which defines the duration of track rendering. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one.

[Source]

     # File xspf-expanded.rb, line 483
483:     def creator
484:       @creator
485:     end

[Source]

     # File xspf-expanded.rb, line 487
487:     def creator=(value)
488:       @creator = value
489:     end

The time to render a resource, in milliseconds. It MUST be a valid XML Schema nonNegativeInteger. This value is only a hint — different XSPF generators will generate slightly different values. A user-agent MUST NOT use this value to determine the rendering duration, since the data will likely be low quality. XSPF::Track objects MAY contain exactly one duration element.

[Source]

     # File xspf-expanded.rb, line 603
603:     def duration
604:       @duration
605:     end

[Source]

     # File xspf-expanded.rb, line 607
607:     def duration=(value)
608:       @duration = value
609:     end

The extension element allows non-XSPF XML to be included in XSPF documents without breaking XSPF validation. The purpose is to allow nested XML, which the meta and link elements do not. XSPF::Track objects MAY contain zero or more extension elements, but currently XSPF for Ruby returns only the first one.

[Source]

     # File xspf-expanded.rb, line 623
623:     def extension
624:       @extension
625:     end

[Source]

     # File xspf-expanded.rb, line 627
627:     def extension=(value)
628:       @extension = value
629:     end

Canonical ID for this resource. Likely to be a hash or other location-independent name, such as a MusicBrainz identifier or isbn URN (if there existed isbn numbers for audio). MUST be a legal URN. XSPF::Track objects elements MAY contain zero or more identifier elements, but currently XSPF for Ruby returns only the first one.

[Source]

     # File xspf-expanded.rb, line 443
443:     def identifier
444:       @identifier
445:     end

[Source]

     # File xspf-expanded.rb, line 447
447:     def identifier=(value)
448:       @identifier = value
449:     end

URL of an image to display for the duration of the track. XSPF::Track objects MAY contain exactly one.

[Source]

     # File xspf-expanded.rb, line 543
543:     def image
544:       @image
545:     end

[Source]

     # File xspf-expanded.rb, line 547
547:     def image=(value)
548:       @image = value
549:     end

URL of a place where this resource can be bought or more info can be found.

[Source]

     # File xspf-expanded.rb, line 523
523:     def info
524:       @info
525:     end

[Source]

     # File xspf-expanded.rb, line 527
527:     def info=(value)
528:       @info = value
529:     end

The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation. A valid link element has a rel attribute and a content element, obtained with XSPF::Track#link_rel and XSPF::Track#link_content respectively. XSPF::Track objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one.

[Source]

     # File xspf-expanded.rb, line 643
643:     def link_content
644:       @link_content
645:     end

[Source]

     # File xspf-expanded.rb, line 647
647:     def link_content=(value)
648:       @link_content = value
649:     end

The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation. A valid link element has a rel attribute and a content element, obtained with XSPF::Track#link_rel and XSPF::Track#link_content respectively. XSPF::Track objects MAY contain zero or more link elements, but currently XSPF for Ruby returns only the first one.

[Source]

     # File xspf-expanded.rb, line 663
663:     def link_rel
664:       @link_rel
665:     end

[Source]

     # File xspf-expanded.rb, line 667
667:     def link_rel=(value)
668:       @link_rel = value
669:     end

URL of resource to be rendered. Probably an audio resource, but MAY be any type of resource with a well-known duration, such as video, a SMIL document, or an XSPF document. The duration of the resource defined in this element defines the duration of rendering. XSPF::Track objects MAY contain zero or more location elements, but a user-agent MUST NOT render more than one of the named resources. Currently, XSPF for Ruby returns only the first location.

[Source]

     # File xspf-expanded.rb, line 423
423:     def location
424:       @location
425:     end

[Source]

     # File xspf-expanded.rb, line 427
427:     def location=(value)
428:       @location = value
429:     end

The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation. A valid meta element has a rel attribute and a content element, obtained with XSPF::Track#meta_rel and XSPF::Track#meta_content respectively. XSPF::Track objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one.

[Source]

     # File xspf-expanded.rb, line 683
683:     def meta_content
684:       @meta_content
685:     end

[Source]

     # File xspf-expanded.rb, line 687
687:     def meta_content=(value)
688:       @meta_content = value
689:     end

The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation. A valid meta element has a rel attribute and a content element, obtained with XSPF::Track#meta_rel and XSPF::Track#meta_content respectively. XSPF::Track objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one.

[Source]

     # File xspf-expanded.rb, line 703
703:     def meta_rel
704:       @meta_rel
705:     end

[Source]

     # File xspf-expanded.rb, line 707
707:     def meta_rel=(value)
708:       @meta_rel = value
709:     end

Human-readable name of the track that authored the resource which defines the duration of track rendering. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one.

[Source]

     # File xspf-expanded.rb, line 463
463:     def title
464:       @title
465:     end

[Source]

     # File xspf-expanded.rb, line 467
467:     def title=(value)
468:       @title = value
469:     end

Exports the XSPF::Track to XML (only the <track> section)

[Source]

     # File lib/xspf.rb, line 444
444:   def to_xml
445: 
446:     xml = REXML::Element.new('track')
447:     
448:     ELEMENTS.each do |element|
449:       # TODO Sure there is a nicer way to do evaluate this condition...
450:       unless eval('@' + element.downcase + '.nil?')
451:         el = REXML::Element.new(element)
452:         el.add_text( eval('@' + element.downcase) )
453:         xml.add_element(el)
454:       end 
455:     end
456: 
457:     ATTRIBUTE_AND_ELEMENT.each do |ae|
458:       # TODO Sure there is a nicer way to do evaluate this condition...
459:       unless eval('@' + ae.downcase + '_rel.nil? && @'+ ae.downcase + '_content.nil?')
460:         el = REXML::Element.new(ae.downcase)
461:         el.add_attribute('rel', eval('@' + ae.downcase + '_rel') )
462:         el.add_text( eval('@' + ae.downcase + '_content') )
463:         xml.add_element(el)
464:       end 
465:     end
466: 
467:     xml.to_s
468:     
469:   end

Integer with value greater than zero giving the ordinal position of the media on the XSPF::Track#album. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one. It MUST be a valid XML Schema nonNegativeInteger.

[Source]

     # File xspf-expanded.rb, line 583
583:     def tracknum
584:       @trackNum
585:     end

[Source]

     # File xspf-expanded.rb, line 587
587:     def tracknum=(value)
588:       @tracknum = value
589:     end

[Validate]