Class: DMAPParser::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/dmapparser/builder.rb

Overview

This class provides a DSL to create DMAP responses

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



7
8
9
# File 'lib/dmapparser/builder.rb', line 7

def initialize
  @dmap_stack = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dmapparser/builder.rb', line 15

def method_missing(method, *args, &block)
  tag = TagDefinition[method]
  return super if tag.nil?

  if block_given? || tag.container?
    fail "Tag #{tag} is not a container type" unless tag.container?
    build_container(tag, &block)
  else
    build_tag(tag, args)
  end
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



5
6
7
# File 'lib/dmapparser/builder.rb', line 5

def result
  @result
end

Class Method Details

.method_missing(method, *args, &block) ⇒ Object



11
12
13
# File 'lib/dmapparser/builder.rb', line 11

def self.method_missing(method, *args, &block)
  new.send(method, *args, &block)
end