alu0101042305 0.1.1
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +35 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/alu0101042305.gemspec +40 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/alu0101042305.rb +13 -0
- data/lib/alu0101042305/label.rb +62 -0
- data/lib/alu0101042305/list.rb +133 -0
- data/lib/alu0101042305/menu.rb +94 -0
- data/lib/alu0101042305/persona.rb +101 -0
- data/lib/alu0101042305/table.rb +45 -0
- data/lib/alu0101042305/version.rb +3 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 061112907a6b5a871bf11cf951cdb942fd110a9b
|
4
|
+
data.tar.gz: 482b82c07040febdf19c912ae5289496c9776ceb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 245d27896c87e04e744780af26b02a798a89a0a118051fa9285bb58508494f901f4d377c4fc4908b8a015c65298e46a3e757895326dae9ad24481c175d1d7186
|
7
|
+
data.tar.gz: 5d03190fdd21b91f637b943442338cfa13f2cf11aa6b667334cb4ca1cd32bb2cf340fdf1a3829cc74e9ecc8ee7f7058702da5044cd311a8e6d492877d1692672
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
alu0101042305 (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.8.0)
|
12
|
+
rspec-core (~> 3.8.0)
|
13
|
+
rspec-expectations (~> 3.8.0)
|
14
|
+
rspec-mocks (~> 3.8.0)
|
15
|
+
rspec-core (3.8.0)
|
16
|
+
rspec-support (~> 3.8.0)
|
17
|
+
rspec-expectations (3.8.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.8.0)
|
20
|
+
rspec-mocks (3.8.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-support (3.8.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
alu0101042305!
|
30
|
+
bundler (~> 1.17)
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.17.1
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Alu0101042305
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/alu0101042305`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'alu0101042305'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install alu0101042305
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/alu0101042305.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "alu0101042305/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "alu0101042305"
|
8
|
+
spec.version = Alu0101042305::VERSION
|
9
|
+
spec.authors = ["Lucas Alonso"]
|
10
|
+
spec.email = ["alu0101042305@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Clase que representa una etiqueta de información nutricional}
|
13
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0101042305.git"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
19
|
+
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
22
|
+
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "alu0101042305"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "alu0101042305/version"
|
2
|
+
require "alu0101042305/label"
|
3
|
+
require "alu0101042305/list"
|
4
|
+
require "alu0101042305/persona"
|
5
|
+
require "alu0101042305/menu"
|
6
|
+
require 'alu0101042305/table'
|
7
|
+
require 'benchmark'
|
8
|
+
include Benchmark
|
9
|
+
|
10
|
+
module Alu0101042305
|
11
|
+
class Error < StandardError; end
|
12
|
+
# Your code goes here...
|
13
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class Label
|
2
|
+
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
attr_reader :nombre, :porcion, :grasas, :grasass, :hc, :azucar, :protei, :sal
|
6
|
+
|
7
|
+
@@ir = {:kj => 8400, :kcal => 2000, :grasas => 70, :grasass => 20,
|
8
|
+
:hc => 260, :azucar => 90, :protei => 50, :sal => 6}
|
9
|
+
|
10
|
+
def initialize(nombre, porcion, grasas, grasass, hc, azucar, protei, sal)
|
11
|
+
@nombre, @porcion, @grasas, @grasass, @hc, @azucar, @protei, @sal =
|
12
|
+
nombre, porcion, grasas, grasass, hc, azucar, protei, sal
|
13
|
+
end
|
14
|
+
|
15
|
+
def kj
|
16
|
+
grasas * 37 + hc * 17 + protei * 17 + sal * 25
|
17
|
+
end
|
18
|
+
|
19
|
+
def kcal
|
20
|
+
grasas * 9 + hc * 4 + protei * 4 + sal * 6
|
21
|
+
end
|
22
|
+
|
23
|
+
def + (label)
|
24
|
+
self.kcal + label.kcal
|
25
|
+
end
|
26
|
+
|
27
|
+
def coerce(arg)
|
28
|
+
[arg,self.kcal]
|
29
|
+
end
|
30
|
+
|
31
|
+
def toX(method, arg = nil)
|
32
|
+
if arg == nil
|
33
|
+
((send(method)*@porcion)/100).round(2)
|
34
|
+
else
|
35
|
+
((send(method, arg)*@porcion)/100).round(2)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def ir(method)
|
40
|
+
((send(method)*100)/@@ir[method]).round(2)
|
41
|
+
end
|
42
|
+
|
43
|
+
def <=>(label)
|
44
|
+
return -1 if self.sal < label.sal
|
45
|
+
return 1 if self.sal > label.sal
|
46
|
+
return self.nombre <=> label.nombre
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
str = String.new
|
51
|
+
str << @nombre << "\n"
|
52
|
+
str << "\t\t\t Por 100g\t IR (100g)\t Por #{@porcion}g\t IR(#{@porcion}g)\n"
|
53
|
+
str << "Valor energético\t #{kj}kJ/#{kcal}kcal\t #{ir(:kcal)}%\t #{toX(:kj)}kJ/#{toX(:kcal)}kcal\t #{toX(:ir,:kcal)}%\n"
|
54
|
+
str <<"Grasas\t\t\t #{@grasas}g\t\t #{ir(:grasas)}%\t\t #{toX(:grasas)}g\t\t #{toX(:ir,:grasas)}%\n"
|
55
|
+
str <<" saturadas:\t\t #{@grasass}g\t\t #{ir(:grasass)}%\t\t #{toX(:grasass)}g\t\t #{toX(:ir,:grasass)}%\n"
|
56
|
+
str <<"Hidratos de carbono\t #{@hc}g\t\t #{ir(:hc)}%\t\t #{toX(:hc)}g\t\t #{toX(:ir,:hc)}%\n"
|
57
|
+
str <<" azúcares:\t\t #{@azucar}g\t\t #{ir(:azucar)}%\t\t #{toX(:azucar)}g\t\t #{toX(:ir,:azucar)}%\n"
|
58
|
+
str <<"Proteínas\t\t #{@protei}g\t\t #{ir(:protei)}%\t\t #{toX(:protei)}g\t\t #{toX(:ir,:protei)}%\n"
|
59
|
+
str <<"Sal\t\t\t #{@sal}g\t\t #{ir(:sal)}%\t\t #{toX(:sal)}g\t\t #{toX(:ir,:sal)}%\n"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
Node = Struct.new(:value, :next, :prev)
|
3
|
+
|
4
|
+
class List
|
5
|
+
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@sz = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def <<(val)
|
13
|
+
node = Node.new(val)
|
14
|
+
if(@head == nil)
|
15
|
+
@head = node
|
16
|
+
@tail = node
|
17
|
+
else
|
18
|
+
node.prev = @tail
|
19
|
+
@tail.next = node
|
20
|
+
@tail = node
|
21
|
+
end
|
22
|
+
@sz += 1
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def unshift(val)
|
27
|
+
node = Node.new(val)
|
28
|
+
if(@head == nil)
|
29
|
+
@head == node
|
30
|
+
@tail == node
|
31
|
+
else
|
32
|
+
node.next = @head
|
33
|
+
@head.prev = node
|
34
|
+
@head = node
|
35
|
+
end
|
36
|
+
@sz -= 1
|
37
|
+
end
|
38
|
+
|
39
|
+
def insert(pos, *arg)
|
40
|
+
node = @head
|
41
|
+
pos.times do
|
42
|
+
if node != nil
|
43
|
+
node = node.next
|
44
|
+
end
|
45
|
+
end
|
46
|
+
if node == @head
|
47
|
+
self.unshift arg[0]
|
48
|
+
self.insert(1, *arg[1, arg.size - 1])
|
49
|
+
else
|
50
|
+
arg.each do |item|
|
51
|
+
if node == nil
|
52
|
+
self << item
|
53
|
+
else
|
54
|
+
newNode = Node.new(item)
|
55
|
+
newNode.prev = node.prev
|
56
|
+
node.prev.next = newNode
|
57
|
+
newNode.next = node
|
58
|
+
node.prev = newNode
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
@sz += 1
|
63
|
+
end
|
64
|
+
|
65
|
+
def pop(n = 1)
|
66
|
+
n.times do
|
67
|
+
if(@tail != nil)
|
68
|
+
@tail = @tail.prev
|
69
|
+
@tail.next = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
@head = nil if @tail == nil
|
73
|
+
@sz -= 1
|
74
|
+
end
|
75
|
+
|
76
|
+
def shift(n = 1)
|
77
|
+
n.times do
|
78
|
+
if @head != nil
|
79
|
+
@head = @head.next
|
80
|
+
@head.prev = nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@tail = nil if @head == nil
|
84
|
+
@sz -= 1
|
85
|
+
end
|
86
|
+
|
87
|
+
def empty?
|
88
|
+
@head == nil
|
89
|
+
end
|
90
|
+
|
91
|
+
def each
|
92
|
+
node = @head
|
93
|
+
while(node != nil)
|
94
|
+
yield node.value
|
95
|
+
node = node.next
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def reverse_each
|
100
|
+
node = @tail
|
101
|
+
while(node != nil)
|
102
|
+
yield node.value
|
103
|
+
node = node.prev
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def for_sort
|
108
|
+
array = self.to_a
|
109
|
+
for i in (0..array.size-2)
|
110
|
+
for j in (i+1..array.size-1)
|
111
|
+
if(array[i] > array[j])
|
112
|
+
aux = array[i]
|
113
|
+
array[i] = array[j]
|
114
|
+
array[j] = aux
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
array
|
119
|
+
end
|
120
|
+
|
121
|
+
def each_sort
|
122
|
+
array = Array.new
|
123
|
+
self.each do |person|
|
124
|
+
sz = array.size
|
125
|
+
array.each_with_index do |person2,i|
|
126
|
+
array.insert(i,person) if person2 > person and sz == array.size
|
127
|
+
end
|
128
|
+
array << person if sz == array.size
|
129
|
+
end
|
130
|
+
array
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
class Menu
|
2
|
+
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
def initialize(day,&block)
|
6
|
+
@day = day
|
7
|
+
@almuerzo = []
|
8
|
+
@cena = []
|
9
|
+
@desayuno = []
|
10
|
+
if block_given?
|
11
|
+
instance_eval &block
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def titulo(str)
|
16
|
+
@title = str
|
17
|
+
end
|
18
|
+
|
19
|
+
def ingesta(h = {})
|
20
|
+
@min = h[:min] if h[:min]
|
21
|
+
@max = h[:max] if h[:max]
|
22
|
+
end
|
23
|
+
|
24
|
+
def desayuno(h = {})
|
25
|
+
@desayuno << Label.new(h[:descripcion],h[:gramos],h[:grasas],0,h[:carbohidratos],0,h[:proteinas],
|
26
|
+
h[:sal])
|
27
|
+
end
|
28
|
+
|
29
|
+
def almuerzo(h = {})
|
30
|
+
@almuerzo << Label.new(h[:descripcion],h[:gramos],h[:grasas],0,h[:carbohidratos],0,h[:proteinas],
|
31
|
+
h[:sal])
|
32
|
+
end
|
33
|
+
|
34
|
+
def cena(h = {})
|
35
|
+
@cena << Label.new(h[:descripcion],h[:gramos],h[:grasas],0,h[:carbohidratos],0,h[:proteinas],
|
36
|
+
h[:sal])
|
37
|
+
end
|
38
|
+
|
39
|
+
def kcal
|
40
|
+
(@desayuno.reduce(:+) + @cena.reduce(:+) + @almuerzo.reduce(:+)).round(2)
|
41
|
+
end
|
42
|
+
|
43
|
+
def <=> (other)
|
44
|
+
self.kcal <=> other.kcal
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
table = Table.new
|
49
|
+
table << @day
|
50
|
+
table << '' << 'grasas' << 'carbohidratos' << 'proteinas' << 'sal' << 'valor energético'
|
51
|
+
table << 'Desayuno'
|
52
|
+
@desayuno.each do |label|
|
53
|
+
table << label.nombre << label.grasas << label.hc << label.protei << label.sal << label.kcal
|
54
|
+
end
|
55
|
+
table << ''
|
56
|
+
table << 'Almuerzo'
|
57
|
+
@almuerzo.each do |label|
|
58
|
+
table << label.nombre << label.grasas << label.hc << label.protei << label.sal << label.kcal
|
59
|
+
end
|
60
|
+
table << ''
|
61
|
+
table << 'Cena'
|
62
|
+
@cena.each do |label|
|
63
|
+
table << label.nombre << label.grasas << label.hc << label.protei << label.sal << label.kcal
|
64
|
+
end
|
65
|
+
table << 'Valor energético total' << self.kcal
|
66
|
+
table.to_s
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.for_sort(menus)
|
70
|
+
for i in (0..menus.size-2)
|
71
|
+
for j in (i+1..menus.size-1)
|
72
|
+
if(menus[i] > menus[j])
|
73
|
+
aux = menus[i];
|
74
|
+
menus[i] = menus[j];
|
75
|
+
menus[j] = aux;
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
menus
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.each_sort(menus)
|
83
|
+
array = Array.new
|
84
|
+
menus.each do |menu|
|
85
|
+
sz = array.size
|
86
|
+
array.each_with_index do |menu2,i|
|
87
|
+
array.insert(i,menu) if menu2 > menu and sz == array.size
|
88
|
+
end
|
89
|
+
array << menu if sz == array.size
|
90
|
+
end
|
91
|
+
array
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
class Persona
|
2
|
+
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
attr_reader :nombre, :sexo
|
6
|
+
|
7
|
+
def initialize(nombre, sexo)
|
8
|
+
@nombre,@sexo = nombre,sexo
|
9
|
+
end
|
10
|
+
|
11
|
+
def <=> other
|
12
|
+
raise TypeError, "Se esperaba un objeto Persona" unless other.is_a?Persona
|
13
|
+
return 1 if other.is_a?PacienteM
|
14
|
+
return @nombre <=> other.nombre
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"#{@nombre} es un#{@sexo == 'mujer' ? 'a' : nil} #{@sexo}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class Paciente < Persona
|
24
|
+
|
25
|
+
attr_reader :consulta
|
26
|
+
|
27
|
+
def initialize(nombre,sexo,consulta)
|
28
|
+
super(nombre,sexo)
|
29
|
+
@consulta = consulta
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
super.to_s + " con consulta en #{@consulta}"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
class PacienteM < Paciente
|
39
|
+
|
40
|
+
attr_reader :peso,:talla,:edad,:cintura,:cadera, :menu
|
41
|
+
|
42
|
+
@@factorAct = {'ninguna' => 0, 'ligera' => 0.12, 'moderada' => 0.27, 'intensa' => 0.54}
|
43
|
+
|
44
|
+
def initialize(nombre,sexo,consulta,peso,talla,edad,cintura,cadera,act = 'ninguna')
|
45
|
+
super(nombre,sexo,consulta)
|
46
|
+
@peso,@talla,@edad,@cintura,@cadera,@act = peso,talla,edad,cintura,cadera,act
|
47
|
+
end
|
48
|
+
|
49
|
+
def addMenu(menu)
|
50
|
+
@menu = menu
|
51
|
+
end
|
52
|
+
|
53
|
+
def menuOk?
|
54
|
+
((total * 0.9)..(total * 1.1)).include? @menu.kcal
|
55
|
+
end
|
56
|
+
|
57
|
+
def pesoIdeal
|
58
|
+
(talla * 100 - 150) * 0.75 + 50
|
59
|
+
end
|
60
|
+
|
61
|
+
def basal
|
62
|
+
(10 * peso + 6.25 * talla * 100 - 5 * edad + (sexo == 'mujer'? -161 : 5)).round(2)
|
63
|
+
end
|
64
|
+
|
65
|
+
def termogeno
|
66
|
+
(basal * 0.1).round(2)
|
67
|
+
end
|
68
|
+
|
69
|
+
def actividad
|
70
|
+
(basal * @@factorAct[@act]).round(2)
|
71
|
+
end
|
72
|
+
|
73
|
+
def total
|
74
|
+
basal + termogeno + actividad
|
75
|
+
end
|
76
|
+
|
77
|
+
def imc
|
78
|
+
@peso/(@talla * @talla)
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s
|
82
|
+
super.to_s + " y en tratamiento"
|
83
|
+
end
|
84
|
+
|
85
|
+
def <=> other
|
86
|
+
raise TypeError, "Se esperaba un objeto Persona" unless other.is_a?Persona
|
87
|
+
return self.imc <=> other.imc if other.is_a?PacienteM
|
88
|
+
return -1
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
class PacienteT < PacienteM
|
94
|
+
|
95
|
+
def <=> other
|
96
|
+
raise TypeError, "Se esperaba un objeto Persona" unless other.is_a?Persona
|
97
|
+
return self.total <=> other.total if other.is_a?PacienteT
|
98
|
+
return -1
|
99
|
+
end
|
100
|
+
#SDGSSD
|
101
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Row < Array
|
2
|
+
|
3
|
+
@@cols = []
|
4
|
+
|
5
|
+
def << parm
|
6
|
+
arg = parm.to_s
|
7
|
+
if(@@cols[size])
|
8
|
+
@@cols[size] = arg.size if arg.size > @@cols[size]
|
9
|
+
else
|
10
|
+
@@cols[size] = arg.size
|
11
|
+
end
|
12
|
+
super arg
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
str = String.new
|
17
|
+
self.each_with_index do |cell,i|
|
18
|
+
str << cell + (' ' * (@@cols[i] - cell.size + 1))
|
19
|
+
end
|
20
|
+
str + "\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Table
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@rows = []
|
29
|
+
end
|
30
|
+
|
31
|
+
def << arg
|
32
|
+
row = Row.new
|
33
|
+
@rows << row
|
34
|
+
row << arg
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
str = String.new
|
39
|
+
@rows.each do |row|
|
40
|
+
str << row.to_s
|
41
|
+
end
|
42
|
+
str
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alu0101042305
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucas Alonso
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-09 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.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- alu0101042305@ull.edu.es
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- alu0101042305.gemspec
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/alu0101042305.rb
|
73
|
+
- lib/alu0101042305/label.rb
|
74
|
+
- lib/alu0101042305/list.rb
|
75
|
+
- lib/alu0101042305/menu.rb
|
76
|
+
- lib/alu0101042305/persona.rb
|
77
|
+
- lib/alu0101042305/table.rb
|
78
|
+
- lib/alu0101042305/version.rb
|
79
|
+
homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0101042305.git
|
80
|
+
licenses: []
|
81
|
+
metadata:
|
82
|
+
allowed_push_host: https://rubygems.org
|
83
|
+
homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0101042305.git
|
84
|
+
source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0101042305.git
|
85
|
+
changelog_uri: 'TODO: Put your gem''s CHANGELOG.md URL here.'
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.5.2.1
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Clase que representa una etiqueta de información nutricional
|
106
|
+
test_files: []
|