Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dx-grid

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dx-grid

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

DX::Grid

The DX::Grid module provides methods for converting between lat/long coordinate pairs and amateur radio Maidenhead grid locators. It can also validate grid coordinators.

The supported grid formats are 4-character (e.g. FN22) and 6-character (e.g. FN32ab).

Installation

Add this line to your application's Gemfile:

gem 'dx-grid'

And then execute:

$ bundle

Or install it yourself as:

$ gem install dx-grid

Usage

require 'dx/grid'

Decoding a Grid to a Coordinate

DX::Grid.decode('FN22') # => [42.5, -75.0]
DX::Grid.decode('FN22ab') # => [42.0625, -75.95833333333333]

Encoding a Coordinate to a Grid

DX::Grid.encode([42.481076, -75.037847]) # => 'FN22'
DX::Grid.encode([42.481076, -75.037847], :length => 4) # => 'FN22'
DX::Grid.encode([42.481076, -75.037847], :length => 6) # => 'FN22cd'

Validating a Grid

DX::Grid.valid?('FN22') # => true
DX::Grid.valid?('fn22') # => true
DX::Grid.valid?('AA00aa') # => true
DX::Grid.valid?('ab12xx') # => true
DX::Grid.valid?('MO00OO') # => true
DX::Grid.valid?('lo00ol') # => true

DX::Grid.valid?('FN') # => false
DX::Grid.valid?('st12') # => false
DX::Grid.valid?('fn22yz') # => false
DX::Grid.valid?('hello world') # => false
DX::Grid.valid?(nil) # => false
DX::Grid.valid?('') # => false
DX::Grid.valid?(5) # => false
DX::Grid.valid?(Math::PI) # => false

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/schrockwell/dx-grid.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 12 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc