Class: ItunesController::SourceKind

Inherits:
Object
  • Object
show all
Defined in:
lib/itunesController/kinds.rb

Overview

Enum of source kinds

Constant Summary collapse

AudioCD =

The Audio CD Source Kind

SourceKind.new(1799439172,"Audio CD")
Device =

The Device Source Kind

SourceKind.new(1799644534,"Device")
IPod =

The iPod Source Kind

SourceKind.new(1800433508,"iPod")
Library =

The Library Source Kind

SourceKind.new(1800169826,"Library")
MP3CD =

The MP3 CD Source Kind

SourceKind.new(1800225604,"MP3 CD")
RadioTuner =

The Radio Tuner Source Kind

SourceKind.new(1800697198,"Radio Tuner")
SharedLibrary =

The Shared Libarary Source Kind

SourceKind.new(1800628324,"Shared Library")
Unknown =

The Unknown Source Kind

SourceKind.new(1800760938,"Unknown")
@@values =
[AudioCD,Device,IPod,Library,MP3CD,RadioTuner,SharedLibrary,Unknown]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, displayName) ⇒ SourceKind

The constructor

Parameters:

  • kind (Number)

    The kind ID

  • displayName (String)

    The kind display name



96
97
98
99
# File 'lib/itunesController/kinds.rb', line 96

def initialize(kind,displayName)
    @kind = kind
    @displayName = displayName
end

Instance Attribute Details

#displayNameObject

Returns the value of attribute displayName.



91
92
93
# File 'lib/itunesController/kinds.rb', line 91

def displayName
  @displayName
end

#kindNumber

The Source kind ID

Returns:

  • (Number)

    the current value of kind



89
90
91
# File 'lib/itunesController/kinds.rb', line 89

def kind
  @kind
end

#StringString

the source display name

Returns:

  • (String)

    the current value of String



89
90
91
# File 'lib/itunesController/kinds.rb', line 89

def String
  @String
end

Class Method Details

.fromKind(kind) ⇒ ItunesController::SourceKind

A class scoped method used to get the kind associated with the kind ID

Parameters:

  • kind

    The kind ID

Returns:



123
124
125
126
127
128
129
130
# File 'lib/itunesController/kinds.rb', line 123

def self.fromKind(kind)
    @@values.each { | v1 |
        if (v1.kind==kind)
        return v1
        end
    }
    return SourceKind.new(v1,"Unknown")
end

Instance Method Details

#to_sObject

Used pretty print the kind to a string

Returns:

  • A string containing the kind display name and ID



134
135
136
# File 'lib/itunesController/kinds.rb', line 134

def to_s            
    return "#{displayName} (#{kind})"
end