Class: Slash::Formats::PeanutsXML

Inherits:
Object
  • Object
show all
Defined in:
lib/slash/peanuts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_type, from_xml_options = {}, to_xml_options = {}) ⇒ PeanutsXML

Returns a new instance of PeanutsXML.



10
11
12
13
# File 'lib/slash/peanuts.rb', line 10

def initialize(response_type, from_xml_options = {}, to_xml_options = {})
  @response_type = response_type
  @to_xml_options, @from_xml_options = to_xml_options, from_xml_options
end

Instance Attribute Details

#from_xml_optionsObject

Returns the value of attribute from_xml_options.



8
9
10
# File 'lib/slash/peanuts.rb', line 8

def from_xml_options
  @from_xml_options
end

#response_typeObject (readonly)

Returns the value of attribute response_type.



7
8
9
# File 'lib/slash/peanuts.rb', line 7

def response_type
  @response_type
end

#to_xml_optionsObject

Returns the value of attribute to_xml_options.



8
9
10
# File 'lib/slash/peanuts.rb', line 8

def to_xml_options
  @to_xml_options
end

Instance Method Details

#decode(data) ⇒ Object



19
20
21
# File 'lib/slash/peanuts.rb', line 19

def decode(data)
  response_type.from_xml(data, from_xml_options)
end

#encode(data) ⇒ Object



15
16
17
# File 'lib/slash/peanuts.rb', line 15

def encode(data)
  data.to_xml(:string, to_xml_options)
end