Class: Freesound::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/freesound/response_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ ResponseParser

Returns a new instance of ResponseParser.



5
6
7
# File 'lib/freesound/response_parser.rb', line 5

def initialize(form)
  @format = form
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



3
4
5
# File 'lib/freesound/response_parser.rb', line 3

def format
  @format
end

Instance Method Details

#parse(raw) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/freesound/response_parser.rb', line 9

def parse(raw)
  case @format
  when :xml
    parse_xml(raw)
  when :yaml, :yml
    parse_yaml(raw)
  else
    parse_json(raw)
  end
end