rectangle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8dd636d4eb3b3f9d7b9b7189a283b20ce6b9ef17
4
+ data.tar.gz: bd78be030821933f7302463322e98098ac6f4805
5
+ SHA512:
6
+ metadata.gz: 7ee057d3e3e5ebd45580cbae372a564458c0cf7a19acf6297d43135c778e94f7737e4fff4ec4809f353cb521da96259d7b8fb8f475352d18a6bded485545aa13
7
+ data.tar.gz: 21babf4fea3aba5fd617de2ba89f5d37a7cab3bbc3dfa03aab2f541894489f1f0090c143880e4a61e5817f2ac34e3103a8931d15148cbc1b48d6631de5334cf9
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rectangle.gemspec
4
+ gemspec
5
+
6
+
7
+ gem 'rspec'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Anton Priadko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Rectangle
2
+
3
+ Implementation of rectangle: represents some rectangular area.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'rectangle'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install rectangle
21
+
22
+ ## Usage
23
+
24
+ ### Creating new rectangle
25
+
26
+ ```ruby
27
+ require 'rectangle'
28
+
29
+ rectangle = Rectangle::Rectangle.new width, height
30
+ ```
31
+
32
+ ### Creating new square
33
+
34
+ ```ruby
35
+ square = Rectangle::Square.new width
36
+ square == Rectangle::Rectangle.new(width, width) #=> true
37
+ ```
38
+
39
+ ### Calculating area
40
+
41
+ ```ruby
42
+ rectangle.area
43
+ ```
44
+
45
+ ### Calculating perimeter
46
+
47
+ ```ruby
48
+ rectangle.perimeter
49
+ ```
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it ( https://github.com/d-ark/rectangle/fork )
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ module Rectangle
2
+ VERSION = "0.1.0"
3
+ end
data/lib/rectangle.rb ADDED
@@ -0,0 +1,39 @@
1
+ require "rectangle/version"
2
+
3
+ module Rectangle
4
+
5
+ # Represents some rectangular area
6
+ class Rectangle
7
+
8
+ def initialize width, height
9
+ @width = width
10
+ @height = height
11
+ end
12
+
13
+ def == other
14
+ other.width == width && other.height == height
15
+ end
16
+
17
+ def area
18
+ width * height
19
+ end
20
+
21
+ def perimeter
22
+ 2 * (width + height)
23
+ end
24
+
25
+ protected
26
+
27
+ attr_reader :width, :height
28
+ end
29
+
30
+
31
+ class Square < Rectangle
32
+
33
+ def initialize width
34
+ super width, width
35
+ end
36
+
37
+ end
38
+
39
+ end
data/rectangle.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rectangle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rectangle"
8
+ spec.version = Rectangle::VERSION
9
+ spec.authors = ["Anton Priadko"]
10
+ spec.email = ["antonpriadko@gmail.com"]
11
+
12
+ spec.summary = %q{Implements rectangle}
13
+ spec.description = %q{Rectangle represents some rectangular area.}
14
+ spec.homepage = "https://github.com/d-ark/rectangle"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rectangle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton Priadko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Rectangle represents some rectangular area.
42
+ email:
43
+ - antonpriadko@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/rectangle.rb
56
+ - lib/rectangle/version.rb
57
+ - rectangle.gemspec
58
+ homepage: https://github.com/d-ark/rectangle
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.5
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Implements rectangle
82
+ test_files: []