hexlet-points 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/points.rb +35 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5aefd0328c98bd9b7bc345c1c0cc8652ea79b3b75a86bde85306983579e08fbb
4
+ data.tar.gz: da1b7d832d9bdeb632944d592d3f93827c7d9fb4817dd03d9b32971c308431d5
5
+ SHA512:
6
+ metadata.gz: 3691ea4bb2be4a7a92220e279fc596c38c21bccb8f4ae11bb5c70b773f713b0320b86f74c6c8674f92f6adacfcadae7c00746cd1af7efaa8b8e4a99b9fe8ca8d
7
+ data.tar.gz: 2ed27defb1c0e3596647f62153723839f897132ab9b3a1e498072388b08383b51c9518a7375229314af960ecc3c422c8b857cd68b10bbed6e4fe54e209fb1033
data/lib/points.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'bundler/setup'
2
+ require 'pairs'
3
+
4
+ module Point
5
+ def self.make(x, y)
6
+ Pairs.cons(x, y)
7
+ end
8
+
9
+ def self.get_x(point)
10
+ Pairs.car(point)
11
+ end
12
+
13
+ def self.get_y(point)
14
+ Pairs.cdr(point)
15
+ end
16
+
17
+ def self.to_string(point)
18
+ Pairs.to_string(point)
19
+ end
20
+
21
+ def self.get_quadrant(point)
22
+ x = get_x(point)
23
+ y = get_y(point)
24
+
25
+ if x.positive?
26
+ return 1 if y.positive?
27
+ return 4 if y.negative?
28
+ end
29
+
30
+ if x.negative?
31
+ return 2 if y.positive?
32
+ return 3 if y.negative?
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hexlet-points
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hexlet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: info@hexlet.io
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/points.rb
20
+ homepage: https://github.com/hexlet-components/ruby-points
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '2.4'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.0.3
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: A SICP'ish Points implemented in Python using hexlet-pairs.
43
+ test_files: []