### Home Classes Methods

### In Files

- lib/xmpp4r/tune/tune.rb

### Parent

XMPPElement

### Methods

- ::new
- #artist
- #length
- #playing?
- #rating
- #source
- #title
- #track
- #uri

### Files

- CHANGELOG
- COPYING
- LICENSE
- README.rdoc
- README_ruby19.txt

### Class/Module Index

Quicksearch

- Jabber
- Jabber::ArgumentError
- Jabber::Bytestreams
- Jabber::Bytestreams::IBB
- Jabber::Bytestreams::IBBInitiator
- Jabber::Bytestreams::IBBQueueItem
- Jabber::Bytestreams::IBBTarget
- Jabber::Bytestreams::IqQueryBytestreams
- Jabber::Bytestreams::IqSi
- Jabber::Bytestreams::IqSiFile
- Jabber::Bytestreams::IqSiFileRange
- Jabber::Bytestreams::SOCKS5Bytestreams
- Jabber::Bytestreams::SOCKS5BytestreamsInitiator
- Jabber::Bytestreams::SOCKS5BytestreamsPeer
- Jabber::Bytestreams::SOCKS5BytestreamsServer
- Jabber::Bytestreams::SOCKS5BytestreamsServerStreamHost
- Jabber::Bytestreams::SOCKS5BytestreamsTarget
- Jabber::Bytestreams::SOCKS5Socket
- Jabber::Bytestreams::StreamHost
- Jabber::Bytestreams::StreamHostUsed
- Jabber::Callback
- Jabber::CallbackList
- Jabber::Caps
- Jabber::Caps::C
- Jabber::Caps::Helper
- Jabber::Client
- Jabber::ClientAuthenticationFailure
- Jabber::Command
- Jabber::Command::IqCommand
- Jabber::Command::Responder
- Jabber::Component
- Jabber::ComponentAuthenticationFailure
- Jabber::Connection
- Jabber::Connection::SSLSocketUTF8
- Jabber::Dataforms
- Jabber::Dataforms::XData
- Jabber::Dataforms::XDataField
- Jabber::Dataforms::XDataInstructions
- Jabber::Dataforms::XDataReported
- Jabber::Dataforms::XDataTitle
- Jabber::Delay
- Jabber::Delay::XDelay
- Jabber::Discovery
- Jabber::Discovery::Feature
- Jabber::Discovery::Helper
- Jabber::Discovery::Identity
- Jabber::Discovery::IqQueryDiscoInfo
- Jabber::Discovery::IqQueryDiscoItems
- Jabber::Discovery::Item
- Jabber::Discovery::Responder
- Jabber::EntityTime
- Jabber::EntityTime::IqTime
- Jabber::EntityTime::Responder
- Jabber::ErrorResponse
- Jabber::FeatureNegotiation
- Jabber::FeatureNegotiation::IqFeature
- Jabber::FileTransfer
- Jabber::FileTransfer::FileSource
- Jabber::FileTransfer::Helper
- Jabber::FileTransfer::TransferSource
- Jabber::Framework
- Jabber::Framework::Base
- Jabber::Framework::Bot
- Jabber::HTTPBinding
- Jabber::HTTPBinding::Client
- Jabber::IdGenerator
- Jabber::InvalidChatState
- Jabber::Iq
- Jabber::IqQuery
- Jabber::JID
- Jabber::JabberError
- Jabber::LastActivity
- Jabber::LastActivity::Helper
- Jabber::LastActivity::IqQueryLastActivity
- Jabber::MUC
- Jabber::MUC::IqQueryMUCAdmin
- Jabber::MUC::IqQueryMUCAdminItem
- Jabber::MUC::IqQueryMUCOwner
- Jabber::MUC::MUCBrowser
- Jabber::MUC::MUCClient
- Jabber::MUC::SimpleMUCClient
- Jabber::MUC::UserItem
- Jabber::MUC::XMUC
- Jabber::MUC::XMUCUser
- Jabber::MUC::XMUCUserInvite
- Jabber::MUC::XMUCUserItem
- Jabber::Message
- Jabber::NoNameXmlnsRegistered
- Jabber::NotConnected
- Jabber::Observable
- Jabber::Observable::Contact
- Jabber::Observable::PubSub
- Jabber::Observable::PubSub::AlreadySet
- Jabber::Observable::PubSub::NoService
- Jabber::Observable::Subscriptions
- Jabber::Presence
- Jabber::PubSub
- Jabber::PubSub::Configuration
- Jabber::PubSub::Event
- Jabber::PubSub::EventItem
- Jabber::PubSub::EventItems
- Jabber::PubSub::IqPubSub
- Jabber::PubSub::IqPubSubOwner
- Jabber::PubSub::Item
- Jabber::PubSub::Items
- Jabber::PubSub::NodeBrowser
- Jabber::PubSub::NodeConfig
- Jabber::PubSub::NodeHelper
- Jabber::PubSub::OAuthPubSubStreamHelper
- Jabber::PubSub::OAuthServiceHelper
- Jabber::PubSub::OwnerNodeConfig
- Jabber::PubSub::Publish
- Jabber::PubSub::Retract
- Jabber::PubSub::ServiceHelper
- Jabber::PubSub::Subscription
- Jabber::PubSub::SubscriptionConfig
- Jabber::PubSub::Unsubscribe
- Jabber::RPC
- Jabber::RPC::Client
- Jabber::RPC::IqQueryRPC
- Jabber::RPC::Server
- Jabber::Reliable
- Jabber::Reliable::Connection
- Jabber::Reliable::Listener
- Jabber::Roster
- Jabber::Roster::Helper
- Jabber::Roster::Helper::RosterItem
- Jabber::Roster::IqQueryRoster
- Jabber::Roster::RosterItem
- Jabber::Roster::RosterX
- Jabber::Roster::RosterXItem
- Jabber::Roster::XRoster
- Jabber::Roster::XRosterItem
- Jabber::SASL
- Jabber::SASL::Anonymous
- Jabber::SASL::Base
- Jabber::SASL::DigestMD5
- Jabber::SASL::Plain
- Jabber::SOCKS5Error
- Jabber::Semaphore
- Jabber::ServerDisconnected
- Jabber::Stream
- Jabber::Stream::ThreadBlock
- Jabber::StreamParser
- Jabber::Test
- Jabber::Test::ListenerMocker
- Jabber::UserLocation
- Jabber::UserLocation::Helper
- Jabber::UserLocation::Location
- Jabber::UserTune
- Jabber::UserTune::Helper
- Jabber::UserTune::Tune
- Jabber::Vcard
- Jabber::Vcard::Helper
- Jabber::Vcard::IqVcard
- Jabber::Version
- Jabber::Version::IqQueryVersion
- Jabber::Version::Responder
- Jabber::Version::SimpleResponder
- Jabber::X
- Jabber::XHTML
- Jabber::XHTML::Body
- Jabber::XHTML::HTML
- Jabber::XMPPElement
- Jabber::XMPPStanza
- Jabber::XParent
- REXML
- REXML::Element
- REXML::IOSource
- XMLRPC
- XMLRPC::Create
- Base64
- ObservableThing
- QObserver
- ThreadStore

No matching classes.

# Jabber::UserTune::Tune

The <tune> XMPP element, as defined in XEP-0118 User Tune

See www.xmpp.org/extensions/xep-0118.html - this element encapsulates metadata (artist, track etc) about a tune the user is currently playing. These are expressed as child elements such as <artist>, <title> etc which are also managed by this class.

If the element has no children then it indicates that the user has stopped playing a tune. Use the Tune#playing? method to discover this?

### Public Class Methods

new(artist = nil, title = nil, length = nil, track = nil, source = nil, uri = nil, rating = nil) click to toggle source

Construct a new <tune> element.

Supply no arguments to make an empty element to indicate that tune playing has stopped.

artist

String

  the artist or performer of the song or piece

title

String

  the title of the song or piece

length

Fixnum

  the duration of the song or piece in seconds

track

String

  a unique identifier for the tune; e.g., the track number within a collection or the specific URI for the object (e.g., a stream or audio file)

source

String

  the collection (e.g., album) or other source (e.g., a band website that hosts streams or audio files)

uri

String

  a URI or URL pointing to information about the song, collection, or artist

rating

Numeric

  a number indicating how much you like this song - will be clamped into an integer 0 <= x <= 10

    # File lib/xmpp4r/tune/tune.rb, line 40
    def initialize(artist = nil, title = nil, length = nil, track = nil, source = nil, uri = nil, rating = nil)
      super()

      add_element(REXML::Element.new('artist')).text = artist if artist

      add_element(REXML::Element.new('title')).text = title if title

      add_element(REXML::Element.new('length')).text = length.to_s if length

      add_element(REXML::Element.new('track')).text = track if track

      add_element(REXML::Element.new('source')).text = source if source

      add_element(REXML::Element.new('uri')).text = uri if uri

      if rating and rating.kind_of?(Numeric)
        r = rating.to_i
        r = 0 if r < 0
        r = 10 if r > 10
        add_element(REXML::Element.new('rating')).text = r.to_s
      end
    end

### Public Instance Methods

artist() click to toggle source

Get the artist for this tune.

    # File lib/xmpp4r/tune/tune.rb, line 72
    def artist
      first_element('artist').text if first_element('artist')
    end

length() click to toggle source

Get the length of this tune, in seconds.

    # File lib/xmpp4r/tune/tune.rb, line 84
    def length
      first_element('length').text.to_i if first_element('length')
    end

playing?() click to toggle source

Returns true if a tune is currently playing, otherwise false.

    # File lib/xmpp4r/tune/tune.rb, line 66
    def playing?
      (elements.size > 0)
    end

rating() click to toggle source

Get the rating for this track

    # File lib/xmpp4r/tune/tune.rb, line 108
    def rating
      first_element('rating').text.to_i if first_element('rating')
    end

source() click to toggle source

Get the source of this tune, such as an album.

    # File lib/xmpp4r/tune/tune.rb, line 96
    def source
      first_element('source').text if first_element('source')
    end

title() click to toggle source

Get the title of this tune.

    # File lib/xmpp4r/tune/tune.rb, line 78
    def title
      first_element('title').text  if first_element('title')
    end

track() click to toggle source

Get an identitier for this tune.

    # File lib/xmpp4r/tune/tune.rb, line 90
    def track
      first_element('track').text if first_element('track')
    end

uri() click to toggle source

Get a URI that represents this tune.

    # File lib/xmpp4r/tune/tune.rb, line 102
    def uri
      first_element('uri').text if first_element('uri')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.