imc_alves 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/imc_alves/version.rb +1 -1
- data/lib/imc_alves.rb +28 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0688d16644a10cec9ae2e2211a58b55613d4940e17d9b192dadf9b296412f29e'
|
4
|
+
data.tar.gz: 97e746da17f725b65cb5623657a07a06813e3026ddf560b23b4908aa315f7974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf87aa6dd87dd11970e3712ffda8b711a6656a3291fb54b69462689bd13f5200820a2478fa09ea226e75d0ead1bc9d4a5e04e48f7e184c2d858abb876fd64db
|
7
|
+
data.tar.gz: 07b6579b592600ea595f9ee91000069e90b40528e3961247858fa803ebf7432347bddb7f5e58cfdc12f7c8253208b62a26376355a51a6acf2df684d883c2ef79
|
data/README.md
CHANGED
@@ -3,18 +3,20 @@
|
|
3
3
|
Gem desenvolvida para calcular o imc e mostrar o Estado Nutricional da pessoa.
|
4
4
|
|
5
5
|
## Installation
|
6
|
-
|
6
|
+
gem install imc_alves
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
10
|
obj = ImcAlves::Pessoa.new(peso, altura)
|
11
11
|
|
12
|
-
print obj.
|
12
|
+
print obj.imc
|
13
|
+
print obj.estado_nutricional
|
14
|
+
|
13
15
|
print obj.status
|
14
16
|
|
15
17
|
## Contributing
|
16
18
|
|
17
|
-
email@example.com
|
19
|
+
email@example.com
|
18
20
|
|
19
21
|
## License
|
20
22
|
|
data/lib/imc_alves/version.rb
CHANGED
data/lib/imc_alves.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "imc_alves/version"
|
4
|
+
require "json"
|
4
5
|
|
5
6
|
module ImcAlves
|
6
7
|
class Error < StandardError; end
|
7
8
|
|
8
9
|
# Classe saúde. Calcular o IMC (Índice de massa corporal)
|
9
10
|
class Pessoa
|
10
|
-
attr_reader :imc, :estado_nutricional
|
11
|
+
attr_reader :imc, :estado_nutricional, :peso_ideal
|
11
12
|
|
12
13
|
# peso | altura
|
13
14
|
def initialize(peso, altura)
|
@@ -29,10 +30,7 @@ module ImcAlves
|
|
29
30
|
}
|
30
31
|
|
31
32
|
@estado_nutricional = est_nutri
|
32
|
-
|
33
|
-
|
34
|
-
def calc_imc
|
35
|
-
(@peso / @altura**2).round(2)
|
33
|
+
@peso_ideal = calc_peso_ideal
|
36
34
|
end
|
37
35
|
|
38
36
|
def status
|
@@ -42,13 +40,36 @@ module ImcAlves
|
|
42
40
|
if @estado_nutricional == :Normal
|
43
41
|
puts "Parabéns! Você está no peso ideal"
|
44
42
|
else
|
45
|
-
|
46
|
-
puts "Seu peso ideal é #{peso}kg"
|
43
|
+
puts "Peso para alcançar Estado Nutricional Normal: #{@peso_ideal}kg"
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
47
|
+
def status_json
|
48
|
+
status = {
|
49
|
+
peso: @peso,
|
50
|
+
altura: @altura,
|
51
|
+
imc: @imc,
|
52
|
+
estado_nutricional: @estado_nutricional,
|
53
|
+
valor_referencia: @est_nut[@estado_nutricional][1],
|
54
|
+
peso_ideal: @peso_ideal
|
55
|
+
}
|
56
|
+
|
57
|
+
JSON.generate(status)
|
58
|
+
end
|
59
|
+
|
50
60
|
private
|
51
61
|
|
62
|
+
def calc_peso_ideal
|
63
|
+
return @peso if @estado_nutricional == :Normal
|
64
|
+
|
65
|
+
imc = @imc < 18.5 ? 19 : 24.5
|
66
|
+
(imc * @altura**2).round(1)
|
67
|
+
end
|
68
|
+
|
69
|
+
def calc_imc
|
70
|
+
(@peso / @altura**2).round(2)
|
71
|
+
end
|
72
|
+
|
52
73
|
def est_nutri
|
53
74
|
@est_nut.each do |k, v|
|
54
75
|
return k if @imc < v[0]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imc_alves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- guinn83
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Calcular o IMC e mostrar o Estado Nutricional da pessoa
|
14
14
|
email:
|