geometer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d25b978e3f91d552021c82298de16a50dd0537d
4
- data.tar.gz: ac066c8251a849686fc4a8cea3ca878da8126707
3
+ metadata.gz: 81894d8f09f311bee538aef764e868e35eda2aa5
4
+ data.tar.gz: e86d15c62527abb38d94a0219749909c68879bbb
5
5
  SHA512:
6
- metadata.gz: 51e1fb185cef34ad4ac1c3b7da5c14cb1c3756d29c65d67409bffd11f122d70a03362708f160afe915900b469c66a3b770004c5a7ec12a46c04b726567159331
7
- data.tar.gz: bb244e0ec5b576331d58587eb25509ae087365cfab39492423a7b627e0d2a3cf9550e39fc376c9231a5e785feec1426b0edeb7cdaba755fe34b59d2720926e02
6
+ metadata.gz: 95acd51102759f105a95d83019eb1b54176d0b0dc017731b949f20107c40c3e5eacbb6fd8f17226155c8fa47571000fd34b8a57abc887a7e68051bfa625fe842
7
+ data.tar.gz: 5d6cd926ce6ce751ebc8d5cb6bbcf23e7813577a15c4720f43db7c3d4be44456bf8f95a6f9da58a9dac95b2064aa19696ca8b3faeab8c5a2f4db77b4283fe7dc
@@ -4,9 +4,20 @@ module Geometer
4
4
  "(#{x},#{y})"
5
5
  end
6
6
 
7
- def -@
7
+ def invert
8
8
  Point.new(-x,-y)
9
9
  end
10
+ alias_method :-@, :invert
11
+
12
+ def scale(sz)
13
+ Point.new(x*sz,y*sz)
14
+ end
15
+ alias_method :*, :scale
16
+
17
+ def divide(sz)
18
+ scale(1.0/sz)
19
+ end
20
+ alias_method :/, :divide
10
21
 
11
22
  def translate(other_point)
12
23
  dx,dy = *other_point
@@ -1,4 +1,4 @@
1
1
  module Geometer
2
2
  # geometer version
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
@@ -8,14 +8,32 @@ describe Geometer do
8
8
  end
9
9
  end
10
10
 
11
+ describe Point do
12
+ include PointHelpers
13
+ let(:a) { coord(0,5) }
14
+ it 'should invert' do
15
+ expect(-a).to eq(coord(0,-5))
16
+ end
17
+
18
+ it 'should scale' do
19
+ expect(a*5).to eq(coord(0,25))
20
+ end
21
+
22
+ it 'should divide' do
23
+ expect(a/2).to eq(coord(0,2.5))
24
+ end
25
+ end
26
+
11
27
  describe Line do
12
28
  include PointHelpers
13
- let(:point_a) { coord(0,3) }
14
- let(:point_b) { coord(4,0) }
15
29
 
16
30
  describe "measuring the hypotenuse" do
17
- it 'should find a 3-4-5 triangle' do
18
- expect(Line.new(point_a,point_b).length).to eq(5)
31
+ context "of a 3-4-5 triangle" do
32
+ let(:point_a) { coord(0,3) }
33
+ let(:point_b) { coord(4,0) }
34
+ it 'should find the hypotenuse to be 5' do
35
+ expect(Line.new(point_a,point_b).length).to eq(5)
36
+ end
19
37
  end
20
38
 
21
39
  it 'should find a 1-1-root(2) triangle' do
@@ -32,9 +50,17 @@ describe Rectangle do
32
50
  let(:origin) { coord(1,1) }
33
51
  let(:dimensions) { dim(2,2) }
34
52
 
35
- it 'should identify points within itself' do
36
- expect(rectangle.contains?(coord(1,1))).to eq(true)
37
- expect(rectangle.contains?(coord(1,0))).to eq(false)
38
- expect(rectangle.contains?(coord(1,-1))).to eq(false)
53
+ describe "#area" do
54
+ it 'should have an area' do
55
+ expect(rectangle.area).to eq(4)
56
+ end
57
+ end
58
+
59
+ describe "#contains?" do
60
+ it 'should identify points within itself' do
61
+ expect(rectangle.contains?(coord(1,1))).to eq(true)
62
+ expect(rectangle.contains?(coord(1,0))).to eq(false)
63
+ expect(rectangle.contains?(coord(1,-1))).to eq(false)
64
+ end
39
65
  end
40
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geometer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler