Class: ItunesController::ServerCommand Abstract

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

Overview

This class is abstract.

Subclass and override #processData to implement a server command

This is the base class of all server commands.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, requiredLoginState, singleThreaded, state, itunes) ⇒ ServerCommand

The constructor



106
107
108
109
110
111
112
# File 'lib/itunesController/controllserver.rb', line 106

def initialize(name,requiredLoginState,singleThreaded,state,itunes)
    @name=name
    @state=state
    @itunes=itunes
    @requiredLoginState=requiredLoginState
    @singleThreaded=singleThreaded
end

Instance Attribute Details

#nameString (readonly)

The command name



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

def name
  @name
end

#requiredLoginStateNumber (readonly)

The required login state need for this command. Either nil, ServerState::NOT_AUTHED, ServerState::DOING_AUTH or ServerState::AUTHED. If nil then works in any login state.



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

def requiredLoginState
  @requiredLoginState
end

#singleThreadedObject (readonly)

Returns the value of attribute singleThreaded.



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

def singleThreaded
  @singleThreaded
end

Instance Method Details

#executeSingleThreaded(state) ⇒ Object

This is executed when the command is popped from the job queue. It is used to force single threaded access to itunes



128
129
# File 'lib/itunesController/controllserver.rb', line 128

def executeSingleThreaded(state)
end

#processData(data, io) ⇒ Boolean, String

This is a virtual method that must be overridden by command classes. This method is used to perform the commands task and return the result to the server.



121
122
123
# File 'lib/itunesController/controllserver.rb', line 121

def processData(data,io)
    raise "ERROR: Your trying to instantiate an abstract class"
end

#processLine(line, io) ⇒ Boolean, String



137
138
139
140
141
142
143
144
# File 'lib/itunesController/controllserver.rb', line 137

def processLine(line,io)
    line = line.chop
    if (line.start_with?(@name))
        ItunesController::ItunesControllerLogging::debug("Command recived: #{@name}")
        return processData(line[@name.length,line.length],io)
    end
    return nil,nil
end