Class: OpenStreetMap::Changeset
- Inherits:
-
Object
- Object
- OpenStreetMap::Changeset
- Defined in:
- lib/open_street_map/changeset.rb
Instance Attribute Summary collapse
-
#closed_at ⇒ Object
When the changeset was closed.
-
#created_at ⇒ Object
Creation date of this changeset.
-
#id ⇒ Object
readonly
Unique ID.
-
#max_lat ⇒ Object
Bounding box surrounding all changes made in this changeset.
-
#max_lon ⇒ Object
Bounding box surrounding all changes made in this changeset.
-
#min_lat ⇒ Object
Bounding box surrounding all changes made in this changeset.
-
#min_lon ⇒ Object
Bounding box surrounding all changes made in this changeset.
-
#open ⇒ Object
True if this changeset is still open.
-
#tags ⇒ Object
readonly
Tags for this object.
-
#uid ⇒ Object
The user id of the user who last edited this object (as read from file, it is not updated by operations to this object) API 0.6 and above only.
-
#user ⇒ Object
The user who last edited this object (as read from file, it is not updated by operations to this object).
Instance Method Summary collapse
-
#attribute_list ⇒ Object
List of attributes for a Changeset.
-
#attributes ⇒ Object
Returns a hash of all non-nil attributes of this object.
-
#initialize(attrs = {}) ⇒ Changeset
constructor
:nodoc:.
-
#open? ⇒ Boolean
Is this changeset still open?.
- #to_xml(options = {}) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Changeset
:nodoc:
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/open_street_map/changeset.rb', line 31 def initialize(attrs = {}) #:nodoc: attrs.stringify_keys! @id = attrs['id'].to_i if attrs['id'] @uid = attrs['uid'].to_i @user = attrs['user'] @created_at = Time.parse(attrs['created_at']) rescue nil @closed_at = Time.parse(attrs['closed_at']) rescue nil @open = attrs['open'] @tags = Tags.new @tags[:created_by] = 'osm for ruby' @min_lat = attrs['min_lat'].to_f @min_lon = attrs['min_lon'].to_f @max_lat = attrs['max_lat'].to_f @max_lon = attrs['max_lon'].to_f end |
Instance Attribute Details
#closed_at ⇒ Object
When the changeset was closed
23 24 25 |
# File 'lib/open_street_map/changeset.rb', line 23 def closed_at @closed_at end |
#created_at ⇒ Object
Creation date of this changeset
20 21 22 |
# File 'lib/open_street_map/changeset.rb', line 20 def created_at @created_at end |
#id ⇒ Object (readonly)
Unique ID
5 6 7 |
# File 'lib/open_street_map/changeset.rb', line 5 def id @id end |
#max_lat ⇒ Object
Bounding box surrounding all changes made in this changeset
26 27 28 |
# File 'lib/open_street_map/changeset.rb', line 26 def max_lat @max_lat end |
#max_lon ⇒ Object
Bounding box surrounding all changes made in this changeset
26 27 28 |
# File 'lib/open_street_map/changeset.rb', line 26 def max_lon @max_lon end |
#min_lat ⇒ Object
Bounding box surrounding all changes made in this changeset
26 27 28 |
# File 'lib/open_street_map/changeset.rb', line 26 def min_lat @min_lat end |
#min_lon ⇒ Object
Bounding box surrounding all changes made in this changeset
26 27 28 |
# File 'lib/open_street_map/changeset.rb', line 26 def min_lon @min_lon end |
#open ⇒ Object
True if this changeset is still open.
17 18 19 |
# File 'lib/open_street_map/changeset.rb', line 17 def open @open end |
#tags ⇒ Object (readonly)
Tags for this object
29 30 31 |
# File 'lib/open_street_map/changeset.rb', line 29 def @tags end |
#uid ⇒ Object
The user id of the user who last edited this object (as read from file, it is not updated by operations to this object) API 0.6 and above only
14 15 16 |
# File 'lib/open_street_map/changeset.rb', line 14 def uid @uid end |
#user ⇒ Object
The user who last edited this object (as read from file, it is not updated by operations to this object)
9 10 11 |
# File 'lib/open_street_map/changeset.rb', line 9 def user @user end |
Instance Method Details
#attribute_list ⇒ Object
List of attributes for a Changeset
59 60 61 |
# File 'lib/open_street_map/changeset.rb', line 59 def attribute_list [:id, :user, :uid, :open, :created_at, :closed_at, :min_lat, :max_lat, :min_lon, :max_lon] end |
#attributes ⇒ Object
Returns a hash of all non-nil attributes of this object.
Keys of this hash are :id
, :user
, and :timestamp
. For a Node also :lon
and :lat
.
call-seq: attributes -> Hash
71 72 73 74 75 76 77 78 |
# File 'lib/open_street_map/changeset.rb', line 71 def attributes attrs = Hash.new attribute_list.each do |attribute| value = self.send(attribute) attrs[attribute] = value unless value.nil? end attrs end |
#open? ⇒ Boolean
Is this changeset still open?
54 55 56 |
# File 'lib/open_street_map/changeset.rb', line 54 def open? ["yes", "1", "t", "true"].include?(open) end |
#to_xml(options = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/open_street_map/changeset.rb', line 80 def to_xml( = {}) xml = [:builder] ||= Builder::XmlMarkup.new xml.instruct! unless [:skip_instruct] xml.osm do xml.changeset(attributes) do .each do |k,v| xml.tag(:k => k, :v => v) end unless .empty? end end end |