geonames_api 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +28 -0
- data/README.md +13 -2
- data/Rakefile +13 -0
- data/geonames_api.gemspec +7 -5
- data/lib/geonames_api.rb +30 -19
- data/lib/geonames_api/alternate_names.rb +54 -0
- data/lib/geonames_api/base.rb +92 -0
- data/lib/geonames_api/children.rb +85 -0
- data/lib/geonames_api/city.rb +8 -0
- data/lib/geonames_api/country.rb +6 -6
- data/lib/geonames_api/country_code.rb +8 -0
- data/lib/geonames_api/country_subdivision.rb +8 -0
- data/lib/geonames_api/earthquake.rb +8 -0
- data/lib/geonames_api/elevation.rb +16 -0
- data/lib/geonames_api/entity.rb +64 -0
- data/lib/geonames_api/error.rb +25 -2
- data/lib/geonames_api/geoname.rb +4 -0
- data/lib/geonames_api/hierarchy.rb +10 -0
- data/lib/geonames_api/list_endpoint.rb +21 -0
- data/lib/geonames_api/nearby_postal_code.rb +17 -0
- data/lib/geonames_api/place.rb +8 -0
- data/lib/geonames_api/place_name.rb +8 -0
- data/lib/geonames_api/place_search.rb +16 -0
- data/lib/geonames_api/postal_code.rb +23 -0
- data/lib/geonames_api/singleton_endpoint.rb +7 -0
- data/lib/geonames_api/street.rb +8 -0
- data/lib/geonames_api/time_zone.rb +17 -14
- data/lib/geonames_api/version.rb +2 -2
- data/lib/geonames_api/weather.rb +16 -16
- data/lib/geonames_api/weather_i_c_a_o.rb +8 -0
- data/lib/geonames_api/wikipedia.rb +5 -5
- data/spec/geonames_api/country_subdivision_spec.rb +27 -0
- data/spec/geonames_api/hierarchy_spec.rb +38 -0
- data/spec/geonames_api/place_name_spec.rb +22 -0
- data/spec/geonames_api/place_search_spec.rb +50 -0
- data/spec/geonames_api/place_spec.rb +17 -0
- data/spec/geonames_api/retry_spec.rb +37 -0
- data/spec/geonames_api/street_spec.rb +22 -0
- data/spec/geonames_api/weather_icao_spec.rb +10 -0
- data/spec/spec_helper.rb +15 -0
- metadata +97 -21
- data/lib/geonames_api/hash.rb +0 -5
- data/lib/geonames_api/object.rb +0 -72
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::Hierarchy do
|
4
|
+
def should_be_sb(h)
|
5
|
+
h.first.name.should == 'Earth'
|
6
|
+
h.map { |ea| ea.name }.should ==
|
7
|
+
['Earth', 'North America', 'United States', 'California', 'Santa Barbara County', 'Santa Barbara']
|
8
|
+
end
|
9
|
+
|
10
|
+
def should_be_roma(h)
|
11
|
+
h.map { |ea| ea.name }.should ==
|
12
|
+
['Terra', 'Europa', 'Italia', 'Lazio', 'Roma', 'Roma', 'Roma']
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '::find' do
|
16
|
+
it 'works for Santa Barbara' do
|
17
|
+
h = GeoNamesAPI::Hierarchy.find(5392952)
|
18
|
+
should_be_sb(h)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'works for Roma ' do
|
22
|
+
begin
|
23
|
+
GeoNamesAPI.lang = :it
|
24
|
+
h = GeoNamesAPI::Hierarchy.find(3169070)
|
25
|
+
should_be_roma(h)
|
26
|
+
ensure
|
27
|
+
GeoNamesAPI.lang = :en
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '::where' do
|
33
|
+
it 'works for Santa Barbara' do
|
34
|
+
h = GeoNamesAPI::Hierarchy.where(geonameId: 5392952)
|
35
|
+
should_be_sb(h)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::PlaceName do
|
4
|
+
describe "::find" do
|
5
|
+
it "should find one place" do
|
6
|
+
result = GeoNamesAPI::PlaceName.find("50.01","10.2")
|
7
|
+
result.should be_present
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should find one place with a hash' do
|
11
|
+
result = GeoNamesAPI::PlaceName.find(lat: 50.01, lng: 10.2)
|
12
|
+
result.should be_present
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "::all" do
|
17
|
+
it "should find maxRow places in 100km radius" do
|
18
|
+
result = GeoNamesAPI::PlaceName.all("50.01","10.2","100", "3")
|
19
|
+
result.count.should == 3
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::PlaceSearch do
|
4
|
+
describe "::where" do
|
5
|
+
it "should search for places dealing with ohio" do
|
6
|
+
search = GeoNamesAPI::PlaceSearch.where(name: 'idaho', maxRows: 10)
|
7
|
+
search.should be_present
|
8
|
+
search.size.should == 10
|
9
|
+
search.results.size.should == 10
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "::find_by_place_name" do
|
14
|
+
it "should find the place by name" do
|
15
|
+
search = GeoNamesAPI::PlaceSearch.find_by_place_name("idaho", 10)
|
16
|
+
search.total_results_count.should > 0
|
17
|
+
search.results.each{|place| place.name.should =~ /idaho/i }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "::find_by_exact_place_name" do
|
22
|
+
it "should find the place by the exact name" do
|
23
|
+
search = GeoNamesAPI::PlaceSearch.find_by_exact_place_name('columbus', 10)
|
24
|
+
search.total_results_count.should > 0
|
25
|
+
search.results.each{|place| place.name.downcase.should == 'columbus' }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#next_page" do
|
30
|
+
it "should grab the next page of results from the same search" do
|
31
|
+
big_search = GeoNamesAPI::PlaceSearch.where(name: 'columbus', maxRows: 9)
|
32
|
+
search_pg1 = GeoNamesAPI::PlaceSearch.where(name: 'columbus', maxRows: 3)
|
33
|
+
search_pg2 = search_pg1.next_page
|
34
|
+
search_pg3 = search_pg2.next_page
|
35
|
+
search_pg1.size.should == 3
|
36
|
+
search_pg2.size.should == 3
|
37
|
+
search_pg3.size.should == 3
|
38
|
+
search_pg3.request_params[:startRow].should == 6
|
39
|
+
(search_pg1.results + search_pg2.results + search_pg3.results).map{|ea|ea.geoname_id}.should == big_search.results.map{|ea|ea.geoname_id}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#to_page" do
|
44
|
+
it "should grab the specified page of results from the same search" do
|
45
|
+
search10 = GeoNamesAPI::PlaceSearch.all("columbus", 10)
|
46
|
+
search2 = GeoNamesAPI::PlaceSearch.all("columbus", 2)
|
47
|
+
search2.to_page(4).first.geoname_id.should == search10.results[8].geoname_id
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::Place do
|
4
|
+
describe "::find" do
|
5
|
+
it "should find one place" do
|
6
|
+
result = GeoNamesAPI::Place.find("50.01","10.2")
|
7
|
+
result.should be_present
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "::all" do
|
12
|
+
it "should find multiple places in 100km radius" do
|
13
|
+
result = GeoNamesAPI::Place.all("50.01","10.2","100")
|
14
|
+
result.size.should > 0
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::Base do
|
4
|
+
TIMEOUT = JSON.load <<-JSON
|
5
|
+
{
|
6
|
+
"status": {
|
7
|
+
"message": "ERROR: canceling statement due to statement timeout",
|
8
|
+
"value": 13
|
9
|
+
}
|
10
|
+
}
|
11
|
+
JSON
|
12
|
+
|
13
|
+
# This is not a correct, complete response, but that's not relevant to the spec:
|
14
|
+
EXAMPLE_RESPONSE = JSON.load <<-JSON
|
15
|
+
{"geonames": [{ "name": "Earth" }]}
|
16
|
+
JSON
|
17
|
+
|
18
|
+
describe "::find" do
|
19
|
+
before :each do
|
20
|
+
GeoNamesAPI.max_sleep_time_between_retries = 0
|
21
|
+
end
|
22
|
+
|
23
|
+
it "retries when geonames returns timeout errors" do
|
24
|
+
GeoNamesAPI::Hierarchy.stub(:make_request).and_return(TIMEOUT, EXAMPLE_RESPONSE)
|
25
|
+
hierarchy = GeoNamesAPI::Hierarchy.find(6295630)
|
26
|
+
earth = hierarchy.first
|
27
|
+
earth.should be_present
|
28
|
+
earth.name.should == "Earth"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "fails when geonames returns timeout errors too many times" do
|
32
|
+
GeoNamesAPI::Hierarchy.stub(:make_request).and_return(TIMEOUT, TIMEOUT, EXAMPLE_RESPONSE)
|
33
|
+
GeoNamesAPI.retries = 1
|
34
|
+
proc { GeoNamesAPI::Hierarchy.find(6295630) }.should raise_error GeoNamesAPI::Timeout
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::Street do
|
4
|
+
describe "::find" do
|
5
|
+
it "should find one Street" do
|
6
|
+
result = GeoNamesAPI::Street.find(37.451, -122.18)
|
7
|
+
result.should be_present
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should not find streets outside of the US" do
|
11
|
+
result = GeoNamesAPI::Street.find(50.01, 10.2)
|
12
|
+
result.should == nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "::all" do
|
17
|
+
it "should find multiple Streets in 100km radius" do
|
18
|
+
result = GeoNamesAPI::Street.all(37.8, -122.4, 1, 3)
|
19
|
+
result.size.should == 3
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'geonames_api'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
if ENV['GEONAMES_USER']
|
8
|
+
GeoNamesAPI.username = ENV['GEONAMES_USER']
|
9
|
+
else
|
10
|
+
puts "Enter your GeoNames WebServices username for running functional specs (press enter to just use default)"
|
11
|
+
name = $stdin.gets.chomp
|
12
|
+
GeoNamesAPI.username = name if name.present?
|
13
|
+
end
|
14
|
+
GeoNamesAPI.logger = Logger.new("test.log")
|
15
|
+
end
|
metadata
CHANGED
@@ -1,97 +1,173 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geonames_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sean Devine
|
8
|
+
- Matthew McEachen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - '>='
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: '0'
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
|
-
- -
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: tzinfo
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
28
40
|
- !ruby/object:Gem::Version
|
29
41
|
version: '0'
|
30
42
|
- !ruby/object:Gem::Dependency
|
31
43
|
name: zipruby
|
32
44
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
45
|
requirements:
|
35
|
-
- -
|
46
|
+
- - '>='
|
36
47
|
- !ruby/object:Gem::Version
|
37
48
|
version: '0'
|
38
49
|
type: :runtime
|
39
50
|
prerelease: false
|
40
51
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
52
|
requirements:
|
43
|
-
- -
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
44
82
|
- !ruby/object:Gem::Version
|
45
83
|
version: '0'
|
46
84
|
description: Simple ruby client for the GeoNames API to get free and easy geographic
|
47
85
|
info.
|
48
86
|
email:
|
49
87
|
- barelyknown@icloud.com
|
88
|
+
- matthew-github@mceachen.org
|
50
89
|
executables: []
|
51
90
|
extensions: []
|
52
91
|
extra_rdoc_files: []
|
53
92
|
files:
|
54
93
|
- .gitignore
|
94
|
+
- .travis.yml
|
95
|
+
- CHANGELOG.md
|
55
96
|
- Gemfile
|
56
97
|
- LICENSE.txt
|
57
98
|
- README.md
|
58
99
|
- Rakefile
|
59
100
|
- geonames_api.gemspec
|
60
101
|
- lib/geonames_api.rb
|
102
|
+
- lib/geonames_api/alternate_names.rb
|
103
|
+
- lib/geonames_api/base.rb
|
104
|
+
- lib/geonames_api/children.rb
|
105
|
+
- lib/geonames_api/city.rb
|
61
106
|
- lib/geonames_api/country.rb
|
107
|
+
- lib/geonames_api/country_code.rb
|
108
|
+
- lib/geonames_api/country_subdivision.rb
|
109
|
+
- lib/geonames_api/earthquake.rb
|
110
|
+
- lib/geonames_api/elevation.rb
|
111
|
+
- lib/geonames_api/entity.rb
|
62
112
|
- lib/geonames_api/error.rb
|
63
|
-
- lib/geonames_api/
|
64
|
-
- lib/geonames_api/
|
113
|
+
- lib/geonames_api/geoname.rb
|
114
|
+
- lib/geonames_api/hierarchy.rb
|
115
|
+
- lib/geonames_api/list_endpoint.rb
|
116
|
+
- lib/geonames_api/nearby_postal_code.rb
|
117
|
+
- lib/geonames_api/place.rb
|
118
|
+
- lib/geonames_api/place_name.rb
|
119
|
+
- lib/geonames_api/place_search.rb
|
120
|
+
- lib/geonames_api/postal_code.rb
|
121
|
+
- lib/geonames_api/singleton_endpoint.rb
|
122
|
+
- lib/geonames_api/street.rb
|
65
123
|
- lib/geonames_api/time_zone.rb
|
66
124
|
- lib/geonames_api/version.rb
|
67
125
|
- lib/geonames_api/weather.rb
|
126
|
+
- lib/geonames_api/weather_i_c_a_o.rb
|
68
127
|
- lib/geonames_api/wikipedia.rb
|
128
|
+
- spec/geonames_api/country_subdivision_spec.rb
|
129
|
+
- spec/geonames_api/hierarchy_spec.rb
|
130
|
+
- spec/geonames_api/place_name_spec.rb
|
131
|
+
- spec/geonames_api/place_search_spec.rb
|
132
|
+
- spec/geonames_api/place_spec.rb
|
133
|
+
- spec/geonames_api/retry_spec.rb
|
134
|
+
- spec/geonames_api/street_spec.rb
|
135
|
+
- spec/geonames_api/weather_icao_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
69
137
|
homepage: https://github.com/buytruckload/geonames_api
|
70
138
|
licenses: []
|
139
|
+
metadata: {}
|
71
140
|
post_install_message:
|
72
141
|
rdoc_options: []
|
73
142
|
require_paths:
|
74
143
|
- lib
|
75
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
145
|
requirements:
|
78
|
-
- -
|
146
|
+
- - '>='
|
79
147
|
- !ruby/object:Gem::Version
|
80
148
|
version: '0'
|
81
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
150
|
requirements:
|
84
|
-
- -
|
151
|
+
- - '>='
|
85
152
|
- !ruby/object:Gem::Version
|
86
153
|
version: '0'
|
87
154
|
requirements: []
|
88
155
|
rubyforge_project:
|
89
|
-
rubygems_version:
|
156
|
+
rubygems_version: 2.0.3
|
90
157
|
signing_key:
|
91
|
-
specification_version:
|
158
|
+
specification_version: 4
|
92
159
|
summary: This is a lightweight client for the GeoNames API. Huge thanks to them for
|
93
160
|
such a great service! There are many GeoNames API clients. BUT, most are rewritten
|
94
161
|
versions of a Java API whose interface is a little funny =| This is a simplified
|
95
|
-
ruby implementation that does not implement the entire API. But,
|
162
|
+
ruby implementation that does not implement the entire API. But, it's lightweight
|
96
163
|
and has a nice interface and will be easy to extend :)
|
97
|
-
test_files:
|
164
|
+
test_files:
|
165
|
+
- spec/geonames_api/country_subdivision_spec.rb
|
166
|
+
- spec/geonames_api/hierarchy_spec.rb
|
167
|
+
- spec/geonames_api/place_name_spec.rb
|
168
|
+
- spec/geonames_api/place_search_spec.rb
|
169
|
+
- spec/geonames_api/place_spec.rb
|
170
|
+
- spec/geonames_api/retry_spec.rb
|
171
|
+
- spec/geonames_api/street_spec.rb
|
172
|
+
- spec/geonames_api/weather_icao_spec.rb
|
173
|
+
- spec/spec_helper.rb
|
data/lib/geonames_api/hash.rb
DELETED
data/lib/geonames_api/object.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
module GeoNamesAPI
|
2
|
-
class Object
|
3
|
-
|
4
|
-
NESTED = true
|
5
|
-
|
6
|
-
def self.find(*names)
|
7
|
-
if response = where(name_params(names)).first
|
8
|
-
new(response)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.all(*names)
|
13
|
-
where(name_params(names)).collect { |response| new(response) if response }.compact
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.where(params={})
|
17
|
-
response = JSON.load(open(url(params)).read)
|
18
|
-
case response.keys.first
|
19
|
-
when /\Astatus\Z/
|
20
|
-
message = response["status"]["message"]
|
21
|
-
raise GeoNamesAPI::Error, message[0,1].capitalize + message[1,message.length - 1]
|
22
|
-
end
|
23
|
-
if self::NESTED
|
24
|
-
[response.values].flatten
|
25
|
-
else
|
26
|
-
[response]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.url(params={})
|
31
|
-
GeoNamesAPI.url + self::METHOD + GeoNamesAPI.params.merge(params).to_url
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.name_params(names)
|
35
|
-
params, n = {}, 0
|
36
|
-
if names.any?
|
37
|
-
[self::ID].flatten.each { |i| params[i] = names[n]; n+= 1 }
|
38
|
-
end
|
39
|
-
params
|
40
|
-
end
|
41
|
-
|
42
|
-
def initialize(response)
|
43
|
-
parse(response)
|
44
|
-
end
|
45
|
-
|
46
|
-
def parse(response)
|
47
|
-
response.each do |key, value|
|
48
|
-
attr_name = create_attribute(key)
|
49
|
-
value = set_default_type(value)
|
50
|
-
send("#{attr_name}=", value)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_attribute(attribute)
|
55
|
-
attr_name = attribute.underscore.to_sym
|
56
|
-
self.class.send(:attr_accessor, attr_name) unless respond_to?(attr_name)
|
57
|
-
attr_name
|
58
|
-
end
|
59
|
-
|
60
|
-
def set_default_type(value)
|
61
|
-
case value
|
62
|
-
when /\A-?\d+\Z/
|
63
|
-
value.to_i
|
64
|
-
when /\A-?\d*\.\d*\Z/
|
65
|
-
value.to_f
|
66
|
-
else
|
67
|
-
value
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|