Skip to content

Commit

Permalink
Rename lng to lon to match EEML
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Aug 26, 2008
1 parent 734fc15 commit 4c8db5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions lib/eeml/location.rb
Expand Up @@ -10,7 +10,7 @@ def initialize(loc_domain, options = {})
set_disposition(options[:disposition])
@name = options[:name]
self.lat = options[:lat]
self.lng = options[:lng]
self.lon = options[:lon]
@ele = options[:ele]
end

Expand Down Expand Up @@ -53,14 +53,14 @@ def lat=(latitude)
end

# Longitude of location
attr_reader :lng
attr_reader :lon

# Set the longitude of the location
def lng=(longitude)
def lon=(longitude)
if longitude && (longitude < -180 || longitude > 180)
raise ArgumentError.new("Longitude must be between -180 and +180")
end
@lng = longitude
@lon = longitude
end

# Elevation of location
Expand Down
18 changes: 9 additions & 9 deletions spec/location_spec.rb
Expand Up @@ -20,13 +20,13 @@
:disposition => :fixed,
:name => "My Room",
:lat => 32.4,
:lng => 22.7,
:lon => 22.7,
:ele => 0.2)
loc.exposure.should == :indoor
loc.disposition.should == :fixed
loc.name.should == "My Room"
loc.lat.should == 32.4
loc.lng.should == 22.7
loc.lon.should == 22.7
loc.ele.should == 0.2
end

Expand Down Expand Up @@ -108,19 +108,19 @@
end

it "can have a longitude" do
lng = 22.7
@loc.lng = lng
@loc.lng.should == lng
lon = 22.7
@loc.lon = lon
@loc.lon.should == lon
end

it "cannot have a longitude outside -180..180" do
lng = 180.1
lon = 180.1
lambda {
@loc.lng = lng
@loc.lon = lon
}.should raise_error(ArgumentError, "Longitude must be between -180 and +180")
lng = -180.1
lon = -180.1
lambda {
@loc.lng = lng
@loc.lon = lon
}.should raise_error(ArgumentError, "Longitude must be between -180 and +180")
end

Expand Down

0 comments on commit 4c8db5c

Please sign in to comment.