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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e0eb413cad23a4b02e2c28d8712a0b1d3f06975fe8a874ab86fe7e8a81d5765
4
- data.tar.gz: c1c9a44b65dfb2018d70861ee6fb1a82ab8464f1981b4258c129cd546363655d
3
+ metadata.gz: '0688d16644a10cec9ae2e2211a58b55613d4940e17d9b192dadf9b296412f29e'
4
+ data.tar.gz: 97e746da17f725b65cb5623657a07a06813e3026ddf560b23b4908aa315f7974
5
5
  SHA512:
6
- metadata.gz: 10180531185699c8d682186e227e2f4cc9a09943ddfaed5192095e28563abeb39ac3460fdc1543b1d1c1e5c7b364e3566b69e23c597bed44f267b498b49371c4
7
- data.tar.gz: f4d1a81db29d7168d734ae33edd5eb96a6dcf765226b8f68dee91aefcf823bd7a4944b12dc6436039aeb44ebd926746063af6cacc0a014fb5289245d6ba1b4ac
6
+ metadata.gz: 5cf87aa6dd87dd11970e3712ffda8b711a6656a3291fb54b69462689bd13f5200820a2478fa09ea226e75d0ead1bc9d4a5e04e48f7e184c2d858abb876fd64db
7
+ data.tar.gz: 07b6579b592600ea595f9ee91000069e90b40528e3961247858fa803ebf7432347bddb7f5e58cfdc12f7c8253208b62a26376355a51a6acf2df684d883c2ef79
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImcAlves
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
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
- peso = (24 * @altura**2).round(1)
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.1.2
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-08 00:00:00.000000000 Z
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: