Sha256: 5a60e7280b3b9f2afd3b47c7d51e09b81b392c4f6cd2905bc584c26679c8d2f4

Contents?: true

Size: 726 Bytes

Versions: 2

Compression:

Stored size: 726 Bytes

Contents

module Rosemary
  # A collection of OSM tags which can be attached to a Node, Way,
  # or Relation.
  # It is a subclass of Hash.
  class Tags < Hash

    # Return XML for these tags. This method uses the Builder library.
    # The only parameter ist the builder object.
    def to_xml(options = {})
      xml = options[:builder] ||= Builder::XmlMarkup.new
      xml.instruct! unless options[:skip_instruct]
      each do |key, value|
        xml.tag(:k => key, :v => value) unless value.blank?
      end unless empty?
    end

    # Return string with comma separated key=value pairs.
    #
    # @return [String] string representation
    #
    def to_s
      sort.collect{ |k, v| "#{k}=#{v}" }.join(', ')
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rosemary-0.3.6 lib/rosemary/tags.rb
rosemary-0.3.5 lib/rosemary/tags.rb