imc_alves 0.1.2 → 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/lib/imc_alves/version.rb +1 -1
- data/lib/imc_alves.rb +24 -3
- 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/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,6 +30,7 @@ module ImcAlves
|
|
29
30
|
}
|
30
31
|
|
31
32
|
@estado_nutricional = est_nutri
|
33
|
+
@peso_ideal = calc_peso_ideal
|
32
34
|
end
|
33
35
|
|
34
36
|
def status
|
@@ -38,13 +40,32 @@ module ImcAlves
|
|
38
40
|
if @estado_nutricional == :Normal
|
39
41
|
puts "Parabéns! Você está no peso ideal"
|
40
42
|
else
|
41
|
-
|
42
|
-
puts "Seu peso ideal é #{peso}kg"
|
43
|
+
puts "Peso para alcançar Estado Nutricional Normal: #{@peso_ideal}kg"
|
43
44
|
end
|
44
45
|
end
|
45
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
|
+
|
46
60
|
private
|
47
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
|
+
|
48
69
|
def calc_imc
|
49
70
|
(@peso / @altura**2).round(2)
|
50
71
|
end
|
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:
|