Skip to content

Commit 2b8ba27

Browse files
committed
Merge pull request #44 from wnameless/master
Add README.md to /ruby
2 parents 6d6f7b8 + 0ba5e9e commit 2b8ba27

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

ruby/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# PlusCodes
2+
3+
Ruby implementation of Google Open Location Code(Plus+Codes)
4+
5+
The latest source code can be found in this
6+
[PlusCodes Gem Github Repo](https://github.com/wnameless/plus_codes-ruby)
7+
8+
## Installation
9+
10+
Add this line to your application's Gemfile:
11+
12+
```ruby
13+
gem 'plus_codes'
14+
```
15+
16+
And then execute:
17+
18+
$ bundle
19+
20+
Or install it yourself as:
21+
22+
$ gem install plus_codes
23+
24+
## Usage
25+
26+
```ruby
27+
require 'plus_codes/open_location_code'
28+
29+
olc = PlusCodes::OpenLocationCode.new
30+
31+
# Encodes the latitude and longitude into a Plus+Codes
32+
code = olc.encode(47.0000625,8.0000625)
33+
# => "8FVC2222+22"
34+
35+
# Encodes any latitude and longitude into a Plus+Codes with preferred length
36+
code = olc.encode(47.0000625,8.0000625, 16)
37+
# => "8FVC2222+22GCCCCC"
38+
39+
# Decodes a Plus+Codes back into coordinates
40+
code_area = olc.decode(code)
41+
puts code_area
42+
# => lat_lo: 47.000062496 long_lo: 8.0000625 lat_hi: 47.000062504 long_hi: 8.000062530517578 code_len: 16
43+
44+
# Checks if a Plus+Codes is valid or not
45+
olc.valid?(code)
46+
# => true
47+
48+
# Checks if a Plus+Codes is full or not
49+
olc.full?(code)
50+
# => true
51+
52+
# Checks if a Plus+Codes is short or not
53+
olc.short?(code)
54+
# => false
55+
56+
# Shorten a Plus+Codes as possible by given reference latitude and longitude
57+
olc.shorten('9C3W9QCJ+2VX', 51.3708675, -1.217765625)
58+
# => "CJ+2VX"
59+
60+
# Extends a Plus+Codes by given reference latitude and longitude
61+
olc.recover_nearest('CJ+2VX', 51.3708675, -1.217765625)
62+
# => "9C3W9QCJ+2VX"
63+
```
64+
65+
## Contributing
66+
67+
1. Fork it ( https://github.com/wnameless/plus_codes-ruby/fork )
68+
2. Create your feature branch (`git checkout -b my-new-feature`)
69+
3. Commit your changes (`git commit -am 'Add some feature'`)
70+
4. Push to the branch (`git push origin my-new-feature`)
71+
5. Create a new Pull Request

0 commit comments

Comments
 (0)