Class: OpenStreetMap::Relation
- Defined in:
- lib/open_street_map/relation.rb
Overview
OpenStreetMap Relation.
To create a new OpenStreetMap::Relation object:
relation = OpenStreetMap::Relation.new()
To get a relation from the API:
relation = OpenStreetMap::Relation.find(17)
Instance Attribute Summary collapse
-
#members ⇒ Object
readonly
Array of Member objects.
Attributes inherited from Element
#changeset, #id, #tags, #timestamp, #uid, #user, #version
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Relation
constructor
Create new Relation object.
-
#to_xml(option = {}) ⇒ Object
Return XML for this relation.
- #type ⇒ Object
Methods inherited from Element
#[], #[]=, #add_tags, #attribute_list, #attributes, from_api, #get_history_from_api, #get_relations_from_api, #initialize_copy, #is_tagged?, #method_missing, #shape, #update_attributes
Constructor Details
#initialize(attrs) ⇒ Relation
Create new Relation object.
If id
is nil
a new unique negative ID will be allocated.
17 18 19 20 21 |
# File 'lib/open_street_map/relation.rb', line 17 def initialize(attrs) attrs.stringify_keys! @members = extract_member(attrs['member']) super(attrs) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OpenStreetMap::Element
Instance Attribute Details
#members ⇒ Object (readonly)
Array of Member objects
12 13 14 |
# File 'lib/open_street_map/relation.rb', line 12 def members @members end |
Instance Method Details
#to_xml(option = {}) ⇒ Object
Return XML for this relation. This method uses the Builder library. The only parameter ist the builder object.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/open_street_map/relation.rb', line 29 def to_xml(option = {}) xml = [:builder] ||= Builder::XmlMarkup.new xml.instruct! unless [:skip_instruct] xml.relation(attributes) do members.each do |member| member.to_xml(:builder => xml, :skip_instruct => true) end .to_xml(:builder => xml, :skip_instruct => true) end end |
#type ⇒ Object
23 24 25 |
# File 'lib/open_street_map/relation.rb', line 23 def type 'relation' end |