Class: Oembed::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/oembed/parser.rb

Constant Summary collapse

SUPPORTED_FORMATS =
{
  'text/xml'               => :xml,
  'application/json'       => :json,
}

Instance Method Summary collapse

Instance Method Details

#parse(body, content_type) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/oembed/parser.rb', line 13

def parse(body, content_type)
  format = SUPPORTED_FORMATS[content_type]

  if format
    send(format, body)
  else
    raise Oembed::NotSupportedFormatError,
        "parser does not support #{format.inspect} format"
  end
end