Class: OpenStreetMap::Tags

Inherits:
Hash
  • Object
show all
Defined in:
lib/open_street_map/tags.rb

Overview

A collection of OSM tags which can be attached to a Node, Way, or Relation. It is a subclass of Hash.

Instance Method Summary collapse

Instance Method Details

#to_sObject

Return string with comma separated key=value pairs.

call-seq: to_s -> String



21
22
23
# File 'lib/open_street_map/tags.rb', line 21

def to_s
  sort.collect{ |k, v| "#{k}=#{v}" }.join(', ')
end

#to_xml(options = {}) ⇒ Object

Return XML for these tags. This method uses the Builder library. The only parameter ist the builder object.



9
10
11
12
13
14
15
# File 'lib/open_street_map/tags.rb', line 9

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)
  end unless empty?
end