Class: MPD::Protocol::Error
- Defined in:
- lib/mpd/protocol/response.rb
Constant Summary collapse
- Codes =
{ NOT_LIST: 1, ARG: 2, PASSWORD: 3, PERMISSION: 4, UNKNOWN: 5, NO_EXIST: 50, PLAYLIST_MAX: 51, SYSTEM: 52, PLAYLIST_LOAD: 53, UPDATE_ALREADY: 54, PLAYER_SYNC: 55, EXIST: 56 }
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Attributes inherited from Response
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(command, data, code, offset, command_name, message) ⇒ Error
constructor
A new instance of Error.
- #success? ⇒ Boolean
- #to_i ⇒ Object
- #to_sym ⇒ Object
Methods inherited from Response
#each, #empty?, read, #to_a, #to_hash
Constructor Details
#initialize(command, data, code, offset, command_name, message) ⇒ Error
Returns a new instance of Error.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/mpd/protocol/response.rb', line 154 def initialize (command, data, code, offset, command_name, ) if !command_name.empty? && command.name != command_name.to_sym raise ArgumentError, 'the passed command object and the response command name do not match' end super(command, data) @code = (code.is_a?(Integer) || Integer(code) rescue false) ? Codes.key(code.to_i) : code.to_sym.upcase @offset = offset.to_i = unless Codes[to_sym] raise ArgumentError, 'the Error code does not exist' end end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
152 153 154 |
# File 'lib/mpd/protocol/response.rb', line 152 def end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
152 153 154 |
# File 'lib/mpd/protocol/response.rb', line 152 def offset @offset end |
Class Method Details
.parse(text) ⇒ Object
148 149 150 |
# File 'lib/mpd/protocol/response.rb', line 148 def self.parse (text) text.match(/^\[(\d+)@(\d+)\] {([^}]*)} (.*?)$/).to_a[1 .. -1] end |
Instance Method Details
#success? ⇒ Boolean
170 |
# File 'lib/mpd/protocol/response.rb', line 170 def success?; false; end |
#to_i ⇒ Object
176 177 178 |
# File 'lib/mpd/protocol/response.rb', line 176 def to_i Codes[to_sym] end |
#to_sym ⇒ Object
172 173 174 |
# File 'lib/mpd/protocol/response.rb', line 172 def to_sym @code end |