abstract class RSS::Element

Direct Known Subclasses

Defined in:

cryss/element.cr

Instance Method Summary

Instance Method Detail

def 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.


[View source]
def to_s(io : IO) #
Description copied from class Reference

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>

[View source]
def to_xml(io : IO) #

Writes the generated XML to the provided io.


[View source]
abstract def to_xml(xml : XML::Builder) #

Writes the generated XML to the provided xml builder.


[View source]