class Oembed::Parser
Constants
- SUPPORTED_FORMATS
Public Instance Methods
parse(body, content_type)
click to toggle source
# 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
Private Instance Methods
json(body)
click to toggle source
# File lib/oembed/parser.rb, line 26 def json(body) begin JSON.parse(body) rescue JSON::JSONError => e raise Oembed::ParserError.new(e), 'JSON parser error' end end
xml(body)
click to toggle source
# File lib/oembed/parser.rb, line 34 def xml(body) Oembed::XmlParser.parse(body) end