Class: Html2rss::ObjectToXmlConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/object_to_xml_converter.rb

Overview

A naive implementation of “Object to XML”: converts a Ruby object to XML format.

Constant Summary collapse

OBJECT_TO_XML_TAGS =
{
  hash: ['<object>', '</object>'],
  enumerable: ['<array>', '</array>']
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ObjectToXmlConverter

Returns a new instance of ObjectToXmlConverter.

Parameters:

  • object (Object)

    any Ruby object (Hash, Array, String, Symbol, etc.)



17
18
19
# File 'lib/html2rss/object_to_xml_converter.rb', line 17

def initialize(object)
  @object = object
end

Instance Method Details

#callString

Converts the object to XML format.

Returns:

  • (String)

    representing the object in XML



25
26
27
# File 'lib/html2rss/object_to_xml_converter.rb', line 25

def call
  object_to_xml(@object)
end