RSS::Element
Inherits Reference / Object
Instance methods
ns(name : String, &)
Adds a non-standard namespaced element to the component.
Yields access to a set of namespaced elements and their values.
Examples taken from here.
channel = RSS::Channel.new(/* ... */)
channel.add_ns(dc: "http://purl.org/dc/elements/1.1")
channel.ns("dc") do |dc|
dc["rights"] = "Copyright 2002"
end
item = RSS::Item.new(title: "New item")
item.ns("dc") do |dc|
dc["subject"] = "CSS"
end
channel << item
If the namespace already exists, it will yield access to the already existing namespace rather than overwriting it. Duplicate keys inside that namespace will overwrite, however.
Note that no sanity checking is (currently) done before serializing an element with a custom
namespaced element, as only the top-level element (a Channel) has access to specifying the
namespace imports.
to_s(io : IO)
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>