dogma.rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5079232ee6960c019d2b4bd739a5f492d26f238dd200bf90eb19ee36facf0b13
4
+ data.tar.gz: ca5f074c183a4e98dafc06e1a26238514517b802de8e06fca6e7b925707630b3
5
+ SHA512:
6
+ metadata.gz: c22b4ac95ee4643fc8859bb372d71d9730f79b5b5764f21f315c6b64b823c6470c94c12253ceb3a0a8ad3a74cd1a959fcc7879e50a7eaa60e7554a43590ddd9e
7
+ data.tar.gz: a2620d57273f10c132d8ef2a23df65602001727c4eb20b5014aaaf8e1a9508f93a969b6be727c3c920e778ea063670c344e18b6b526af676ff73cf6815fc995a
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ * Arto Bendiken <arto@bendiken.net>
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
@@ -0,0 +1 @@
1
+ # Credits
@@ -0,0 +1,48 @@
1
+ # Dogma for Ruby
2
+
3
+ [![Project license](https://img.shields.io/badge/license-Public%20Domain-blue.svg)](https://unlicense.org)
4
+ [![Ruby compatibility](https://img.shields.io/badge/ruby-2.7%2B-blue)](https://rubygems.org/gems/dogma.rb)
5
+ [![RubyGems gem](https://img.shields.io/gem/v/dogma.rb.svg)](https://rubygems.org/gems/dogma.rb)
6
+ [![Continuous integration](https://github.com/dogmatists/dogma.rb/workflows/Continuous%20integration/badge.svg)](https://github.com/dogmatists/dogma.rb/actions?query=workflow%3A%22Continuous+integration%22)
7
+
8
+ <https://dogma.dev>
9
+
10
+ ## Prerequisites
11
+
12
+ - [Ruby](https://www.ruby-lang.org/en/) 2.7+
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ $ gem install dogma.rb
18
+ ```
19
+
20
+ ## Examples
21
+
22
+ ### Importing the library
23
+
24
+ ```ruby
25
+ require 'dogma'
26
+ ```
27
+
28
+ ### Checking the library version
29
+
30
+ ## Reference
31
+
32
+ ### Classes
33
+
34
+ - [`Dogma::Angle`](https://dogma.dev/Angle/)
35
+ - [`Dogma::Latitude`](https://dogma.dev/Latitude/)
36
+ - [`Dogma::Longitude`](https://dogma.dev/Longitude/)
37
+
38
+ ## See Also
39
+
40
+ Dogma for [C][], [C++][], [Dart][], [Protobuf][], [Python][], and [Zig][].
41
+
42
+ [C]: https://github.com/dogmatists/dogma.c
43
+ [C++]: https://github.com/dogmatists/dogma.cpp
44
+ [Dart]: https://github.com/dogmatists/dogma.dart
45
+ [Protobuf]: https://github.com/dogmatists/dogma.pb
46
+ [Python]: https://github.com/dogmatists/dogma.py
47
+ [Ruby]: https://github.com/dogmatists/dogma.rb
48
+ [Zig]: https://github.com/dogmatists/dogma.zig
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org/>
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,7 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require_relative 'dogma/version'
4
+
5
+ require_relative 'dogma/angle'
6
+ require_relative 'dogma/latitude'
7
+ require_relative 'dogma/longitude'
@@ -0,0 +1,47 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ ##
4
+ # An angle.
5
+ #
6
+ # @see https://dogma.dev/Angle/
7
+ class Dogma::Angle
8
+ # @return [Float]
9
+ attr_reader :radians
10
+
11
+ ##
12
+ # @param [Float, #to_f] degrees
13
+ # @param [Float, #to_f] radians
14
+ # @param [Float, #to_f] turns
15
+ # @return [void]
16
+ def initialize(degrees: nil, radians: nil, turns: nil)
17
+ @radians = case
18
+ when radians then radians.to_f
19
+ when degrees then degrees.to_f/180 * Math::PI
20
+ when turns then turns * 2*Math::PI
21
+ end
22
+ end
23
+
24
+ ##
25
+ # @return [Float]
26
+ def to_f
27
+ self.radians
28
+ end
29
+
30
+ ##
31
+ # @return [Float]
32
+ def as_degrees
33
+ self.radians/Math::PI * 180
34
+ end
35
+
36
+ ##
37
+ # @return [Float]
38
+ def as_radians
39
+ self.radians
40
+ end
41
+
42
+ ##
43
+ # @return [Float]
44
+ def as_turns
45
+ self.radians / (2*Math::PI)
46
+ end
47
+ end # Dogma::Angle
@@ -0,0 +1,21 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require_relative 'angle'
4
+
5
+ ##
6
+ # A latitude.
7
+ #
8
+ # @see https://dogma.dev/Latitude/
9
+ class Dogma::Latitude < Dogma::Angle
10
+ MIN = -90
11
+ MAX = 90
12
+
13
+ ##
14
+ # @param [Float, #to_f] degrees (-90..90)
15
+ # @return [void]
16
+ def initialize(degrees)
17
+ degrees = degrees.to_f
18
+ raise ArgumentError, "Latitude bounds are ±90°, but got #{degrees}°" if degrees.abs > MAX
19
+ super(degrees: degrees)
20
+ end
21
+ end # Dogma::Latitude
@@ -0,0 +1,21 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require_relative 'angle'
4
+
5
+ ##
6
+ # A longitude.
7
+ #
8
+ # @see https://dogma.dev/Longitude/
9
+ class Dogma::Longitude < Dogma::Angle
10
+ MIN = -180
11
+ MAX = 180
12
+
13
+ ##
14
+ # @param [Float, #to_f] degrees (-180..180)
15
+ # @return [void]
16
+ def initialize(degrees)
17
+ degrees = degrees.to_f
18
+ raise ArgumentError, "Longitude bounds are ±180°, but got #{degrees}°" if degrees.abs > MAX
19
+ super(degrees: degrees)
20
+ end
21
+ end # Dogma::Longitude
@@ -0,0 +1,21 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Dogma
4
+ module VERSION
5
+ FILE = File.expand_path('../../VERSION', __dir__).freeze
6
+ STRING = File.read(FILE).chomp.freeze
7
+ MAJOR, MINOR, TINY, EXTRA = STRING.split('.').map(&:to_i).freeze
8
+
9
+ ##
10
+ # @return [String]
11
+ def self.to_s() STRING end
12
+
13
+ ##
14
+ # @return [String]
15
+ def self.to_str() STRING end
16
+
17
+ ##
18
+ # @return [Array(Integer, Integer, Integer)]
19
+ def self.to_a() [MAJOR, MINOR, TINY].freeze end
20
+ end # VERSION
21
+ end # Dogma
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dogma.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Arto Bendiken
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ description: Dogma for Ruby.
56
+ email: arto@bendiken.net
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - AUTHORS
62
+ - CHANGES.md
63
+ - CREDITS.md
64
+ - README.md
65
+ - UNLICENSE
66
+ - VERSION
67
+ - lib/dogma.rb
68
+ - lib/dogma/angle.rb
69
+ - lib/dogma/latitude.rb
70
+ - lib/dogma/longitude.rb
71
+ - lib/dogma/version.rb
72
+ homepage: https://github.com/dogmatists/dogma.rb
73
+ licenses:
74
+ - Unlicense
75
+ metadata:
76
+ bug_tracker_uri: https://github.com/dogmatists/dogma.rb/issues
77
+ changelog_uri: https://github.com/dogmatists/dogma.rb/blob/master/CHANGES.md
78
+ documentation_uri: https://www.rubydoc.info/github/dogmatists/dogma.rb/master
79
+ homepage_uri: https://github.com/dogmatists/dogma.rb
80
+ source_code_uri: https://github.com/dogmatists/dogma.rb
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.7.0
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 3.1.2
95
+ requirements: []
96
+ rubygems_version: 3.1.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Dogma for Ruby.
100
+ test_files: []