bmicalc 0.0.1 → 0.0.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: 818200964f70024d929faf55c2e4f19b00f5c47d
4
- data.tar.gz: abdf36b65d1b41fc4f66482a7ca57d0b9c2dd67c
3
+ metadata.gz: 5b54dd21218de2e8062ae2318c58c6cf2038f296
4
+ data.tar.gz: c658de88014e818dfd3dc52e0b34adc4bc52ae1b
5
5
  SHA512:
6
- metadata.gz: 46065139456ffe25d8315c7d6e91a435dbb84e286d023af75ad8b0fd98656906b8a2cbe9a2825746bcfeeca98ec533f9290c58774e098ae75d7075fcf472020f
7
- data.tar.gz: d56f2babfd4389948a3d72ef2e6cbe8f341ff13de05a259e71a7e83e325a92ed5c62b55cfcef722ff871a7f2d4577d59908b12bf2f41fdfcb81d18bec76080b6
6
+ metadata.gz: ba19def99612fd9bfcb1b932a4194351b301b2310473a90dbf9d864f2423d10375364b03af64bdbb84e7c3172caf27cb62967eaa66b58b4d99469c272e7b7aaf
7
+ data.tar.gz: 88c81c056436cbc273d6a262a5e797704e4905773761e1640259d22c3d0ab1c2553ef52b14243046122e7fa1ff5a35087d506f1887e947283e7417e8bfcec4f7
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- =======
2
- bmicalc
1
+ Bmi Calc
3
2
  =======
4
3
 
5
4
  Gem to calculate BMI
@@ -20,15 +19,25 @@ Or install it yourself as:
20
19
 
21
20
  ## Usage
22
21
 
22
+ require 'bmicalc'
23
+
23
24
  bmi = Bmicalc.new
24
25
  bmi.weight = 64 # in KGs
25
26
  bmi.height = 1.78 # in meters
26
27
 
27
28
  bmi.result # 20
28
29
 
30
+ ### Result without rounding
31
+
32
+ bmi = Bmicalc.new(round: false)
33
+ bmi.weight = 64 # in KGs
34
+ bmi.height = 1.78 # in meters
35
+
36
+ bmi.result # 20.199469763918696
37
+
29
38
  ## Contributing
30
39
 
31
- 1. Fork it ( http://github.com/<my-github-username>/bmicalc/fork )
40
+ 1. Fork it ( http://github.com/tomkadwill/bmicalc/fork )
32
41
  2. Create your feature branch (`git checkout -b my-new-feature`)
33
42
  3. Commit your changes (`git commit -am 'Add some feature'`)
34
43
  4. Push to the branch (`git push origin my-new-feature`)
data/bmicalc.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["tomkadwill@gmail.com"]
11
11
  spec.summary = %q{Calculate BMI}
12
12
  spec.description = %q{Calculate BMI}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/tomkadwill/bmicalc.git"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -1,3 +1,3 @@
1
1
  class Bmicalc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/bmicalc.rb CHANGED
@@ -4,7 +4,11 @@ class Bmicalc
4
4
 
5
5
  attr_accessor :weight, :height
6
6
 
7
- def result
7
+ def initialize(options = {})
8
+ @round = options.fetch(:round, true)
9
+ end
10
+
11
+ def result(options = {})
8
12
  error unless weight && height
9
13
  calculate_result
10
14
  end
@@ -12,7 +16,11 @@ class Bmicalc
12
16
  private
13
17
 
14
18
  def calculate_result
15
- (weight / (height * height)).round
19
+ if @round
20
+ (weight / (height * height)).round
21
+ else
22
+ weight / (height * height)
23
+ end
16
24
  end
17
25
 
18
26
  def error
data/spec/bmicalc_spec.rb CHANGED
@@ -39,4 +39,11 @@ describe Bmicalc do
39
39
  proc { subject.result }.should raise_error(StandardError, 'height not set')
40
40
  end
41
41
 
42
+ it 'returns bmi without rounding' do
43
+ bmi = Bmicalc.new(round: false)
44
+ bmi.weight = 64
45
+ bmi.height = 1.78
46
+ expect(bmi.result).to eq(20.199469763918696)
47
+ end
48
+
42
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmicalc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Kadwill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-01 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,7 +69,7 @@ files:
69
69
  - lib/bmicalc.rb
70
70
  - lib/bmicalc/version.rb
71
71
  - spec/bmicalc_spec.rb
72
- homepage: ''
72
+ homepage: https://github.com/tomkadwill/bmicalc.git
73
73
  licenses:
74
74
  - MIT
75
75
  metadata: {}