Class: DMAPParser::Parser
- Inherits:
-
Object
- Object
- DMAPParser::Parser
- Defined in:
- lib/dmapparser/parser.rb
Overview
The DMAPParser class parses DMAP responses
Constant Summary collapse
- ParseError =
Class.new(StandardError)
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(response) ⇒ Parser
Returns a new instance of Parser.
14 15 16 17 18 |
# File 'lib/dmapparser/parser.rb', line 14 def initialize(response) @response = response @response = StringIO.new(response) unless @response.is_a? IO @response.set_encoding(Encoding::BINARY) end |
Class Method Details
.parse(response) ⇒ Object
10 11 12 |
# File 'lib/dmapparser/parser.rb', line 10 def self.parse(response) new(response).parse end |
Instance Method Details
#parse ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/dmapparser/parser.rb', line 20 def parse fail ParseError if @response.nil? || @response.size < 8 ret = TagContainer.new(read_key) fail ParseError if ret.type && !ret.type.container? ret.value = parse_container(read_length) ret end |