alimento-0100895001 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +12 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Guardfile +82 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/alimento.gemspec +40 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Alimento.html +110 -0
- data/docs/Alimento_.html +406 -0
- data/docs/Gemfile.html +100 -0
- data/docs/Gemfile_lock.html +213 -0
- data/docs/Grupo_alimento.html +232 -0
- data/docs/Guardfile.html +177 -0
- data/docs/List.html +511 -0
- data/docs/Object.html +129 -0
- data/docs/README_md.html +169 -0
- data/docs/Rakefile.html +98 -0
- data/docs/alimento_gemspec.html +133 -0
- data/docs/bin/setup.html +98 -0
- data/docs/created.rid +17 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +590 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +110 -0
- data/docs/js/darkfish.js +161 -0
- data/docs/js/jquery.js +4 -0
- data/docs/js/navigation.js +142 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +109 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +165 -0
- data/lib/alimento.rb +8 -0
- data/lib/alimento/alimento_.rb +73 -0
- data/lib/alimento/list.rb +108 -0
- data/lib/alimento/plato.rb +169 -0
- data/lib/alimento/version.rb +3 -0
- metadata +227 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0cb9d7be86771cbc82ac7246cd4b73551a92923c
|
4
|
+
data.tar.gz: f1ad7ceb8df4aff6ab07a46640e980dec8b72773
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19bbadcd1484362e9672dff245fe9731bec326aed6ca37240c975632f8a67baaae76a1156dbec4394cb71c9b570c3a359c2bef2df1232037991133439ca48903
|
7
|
+
data.tar.gz: efcba0f69c47d5bda616bdb1683fee8f739edf4fbeb2c3d0835b735d70306ce172a8b85f19cc7a91b0b7e29e8f0b90f762189973dbee02996315bc1f9ee87f95
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :bundler do
|
19
|
+
require 'guard/bundler'
|
20
|
+
require 'guard/bundler/verify'
|
21
|
+
helper = Guard::Bundler::Verify.new
|
22
|
+
|
23
|
+
files = ['Gemfile']
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
25
|
+
|
26
|
+
# Assume files are symlinked from somewhere
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
32
|
+
# * bundler: 'bundle exec rspec'
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
35
|
+
# installed the spring binstubs per the docs)
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
37
|
+
# * 'just' rspec: 'rspec'
|
38
|
+
|
39
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
40
|
+
require "guard/rspec/dsl"
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
42
|
+
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
44
|
+
|
45
|
+
# RSpec files
|
46
|
+
rspec = dsl.rspec
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
49
|
+
watch(rspec.spec_files)
|
50
|
+
|
51
|
+
# Ruby files
|
52
|
+
ruby = dsl.ruby
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
54
|
+
|
55
|
+
# Rails files
|
56
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
57
|
+
dsl.watch_spec_files_for(rails.app_files)
|
58
|
+
dsl.watch_spec_files_for(rails.views)
|
59
|
+
|
60
|
+
watch(rails.controllers) do |m|
|
61
|
+
[
|
62
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
63
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
64
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Rails config changes
|
69
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
70
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
71
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
72
|
+
|
73
|
+
# Capybara features specs
|
74
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
76
|
+
|
77
|
+
# Turnip features and steps
|
78
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
79
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
80
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
81
|
+
end
|
82
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Práctica 11. Lenguaje de dominio específico
|
2
|
+
|
3
|
+
## Carla Ramos Alonso
|
4
|
+
|
5
|
+
Práctica 11 de la asignatura de Lenguajes y paradigmas de la programación.
|
6
|
+
En dicha práctica haremos uso de las prácticas anteriores, y utilizaremos la clase
|
7
|
+
Alimento_ y List que en nuestro caso definen una lista doblemente enlazada de alimentos, que
|
8
|
+
a su vez pertenecen a un grupo, ya que hemos hecho uso de la herencia.
|
9
|
+
Hemos hecho uso de los mixin de Ruby **Enumerable** y **Comparable**. Además, en esta práctica hacemos uso del paradigma de programación funcional
|
10
|
+
y hemos calculado el **aibc** y el **ig** de los alimentos y de los distintos individuos. La nueva funcionalidad añadida es la ordenación de una determinada lista de alimentos
|
11
|
+
mediante tres métodos diferentes: **for**, **each** y **sort**.
|
12
|
+
|
13
|
+
Las herramientas que hemos usado para el desarrollo de la misma son las siguientes:
|
14
|
+
|
15
|
+
__Bundler:__ Manejo de gemas
|
16
|
+
__Rspec:__ Desarrollo dirigido por pruebas
|
17
|
+
__Guard:__ Comprobación continua
|
18
|
+
__Travis:__ Ejecución de los resultados
|
19
|
+
__Benchmark:__ Informe de tiempo (banco de pruebas)
|
20
|
+
__Coveralls:__ Devuelve el cubrimiento y las estadísticas del código Ruby desarrollado
|
21
|
+
|
22
|
+
Usaremos la metodología del **desarrollo dirigido por pruebas**, que consiste en la definición de las pruebas, con el resultado que esperamos, y luego la implementación del mínimo código necesario para el éxito de la misma.
|
23
|
+
Los **DSL** son herramientas útiles que permiten expresar fácilmente la lógica específica de un problema particular
|
24
|
+
(dominio) que de otro modo será difícil o farragoso de escribir en otro idioma.
|
25
|
+
## Interpretación
|
26
|
+
|
27
|
+
Para la interpretación del programa tendremos tan solo que modificar los ficheros de pruebas o clicar enter en la consola con la ejecución de guard, ya que este nos permite ver la ejecución de las pruebas cada vez que estas se modifiquen.
|
28
|
+
Para ello ejecutaremos:
|
29
|
+
`bundle exec guard`
|
30
|
+
|
31
|
+
## Resultado
|
32
|
+
|
33
|
+
Se podrán insertar alimentos a la lista, y además extraer el primero o el último.
|
34
|
+
El programa también hace uso de **herencia** con Ruby, de manera que los alimentos están clasificados por grupos de alimentos, que es una clase heredada de la clase alimento creada en las prácticas anteriores.
|
35
|
+
A su vez, gracias a los **mixin** implementados, podremos obtener el maximo valor en la lista, el menor, desordenarla, definir un bloque para que se cumpla en los elementos de la lista, etc.
|
36
|
+
Tenemos también el resultado del AIBC y además los IG de los alimentos (yogurt, chocolate y compota de manzana) y de los dos individuos instanciados.
|
37
|
+
Tras la ordenación de la lista obtendremos una lista ordenada utilizando los valores energéticos de cada alimento.
|
38
|
+
|
39
|
+
|
40
|
+
## Documentación
|
41
|
+
|
42
|
+
Para generar la documentación en Ruby he hecho uso de la herramienta **rdoc** la cual he instalado mediante:
|
43
|
+
`gem install rdoc`
|
44
|
+
Y tras haber comentado el código fuente he generado la documentación con:
|
45
|
+
`rdoc`
|
46
|
+
Se ha generado un directorio **docs** en mi directorio de trabajo en el que se incluye el fichero donde se puede encontrar toda la documentación:
|
47
|
+
|
48
|
+
__docs/index.html__
|
49
|
+
|
50
|
+
|
data/Rakefile
ADDED
data/alimento.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "alimento/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "alimento-0100895001"
|
8
|
+
spec.version = Alimento::VERSION
|
9
|
+
spec.authors = ["carlarxmos"]
|
10
|
+
spec.email = ["carlaramosalonso@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gema que describe un alimento.}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1718/tdd-carlaramos.git"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
#if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "https://github.com/ULL-ESIT-LPP-1718/tdd-carlaramos.git"
|
20
|
+
#else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency "guard"
|
36
|
+
spec.add_development_dependency "guard-rspec"
|
37
|
+
spec.add_development_dependency "guard-bundler"
|
38
|
+
spec.add_development_dependency "guard-rdoc"
|
39
|
+
spec.add_development_dependency "coveralls"
|
40
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "alimento"
|
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
data/docs/Alimento.html
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module Alimento - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/jquery.js"></script>
|
15
|
+
<script src="./js/darkfish.js"></script>
|
16
|
+
|
17
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<body id="top" role="document" class="module">
|
23
|
+
<nav role="navigation">
|
24
|
+
<div id="project-navigation">
|
25
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
+
<h2>
|
27
|
+
<a href="./index.html" rel="home">Home</a>
|
28
|
+
</h2>
|
29
|
+
|
30
|
+
<div id="table-of-contents-navigation">
|
31
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
32
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
33
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
+
<form action="#" method="get" accept-charset="utf-8">
|
39
|
+
<div id="search-field-wrapper">
|
40
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
+
aria-autocomplete="list" aria-controls="search-results"
|
42
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<ul id="search-results" aria-label="Search Results"
|
47
|
+
aria-busy="false" aria-expanded="false"
|
48
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
+
</form>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
</div>
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
<div id="class-metadata">
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
</div>
|
63
|
+
</nav>
|
64
|
+
|
65
|
+
<main role="main" aria-labelledby="module-Alimento">
|
66
|
+
<h1 id="module-Alimento" class="module">
|
67
|
+
module Alimento
|
68
|
+
</h1>
|
69
|
+
|
70
|
+
<section class="description">
|
71
|
+
|
72
|
+
</section>
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<section class="constants-list">
|
84
|
+
<header>
|
85
|
+
<h3>Constants</h3>
|
86
|
+
</header>
|
87
|
+
<dl>
|
88
|
+
|
89
|
+
<dt id="VERSION">VERSION
|
90
|
+
|
91
|
+
<dd>
|
92
|
+
|
93
|
+
|
94
|
+
</dl>
|
95
|
+
</section>
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
</section>
|
102
|
+
</main>
|
103
|
+
|
104
|
+
|
105
|
+
<footer id="validator-badges" role="contentinfo">
|
106
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
107
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
108
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
109
|
+
</footer>
|
110
|
+
|
data/docs/Alimento_.html
ADDED
@@ -0,0 +1,406 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Alimento_ - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/jquery.js"></script>
|
15
|
+
<script src="./js/darkfish.js"></script>
|
16
|
+
|
17
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<body id="top" role="document" class="class">
|
23
|
+
<nav role="navigation">
|
24
|
+
<div id="project-navigation">
|
25
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
+
<h2>
|
27
|
+
<a href="./index.html" rel="home">Home</a>
|
28
|
+
</h2>
|
29
|
+
|
30
|
+
<div id="table-of-contents-navigation">
|
31
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
32
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
33
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
+
<form action="#" method="get" accept-charset="utf-8">
|
39
|
+
<div id="search-field-wrapper">
|
40
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
+
aria-autocomplete="list" aria-controls="search-results"
|
42
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<ul id="search-results" aria-label="Search Results"
|
47
|
+
aria-busy="false" aria-expanded="false"
|
48
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
+
</form>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
</div>
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
<div id="class-metadata">
|
57
|
+
|
58
|
+
<div id="parent-class-section" class="nav-section">
|
59
|
+
<h3>Parent</h3>
|
60
|
+
|
61
|
+
|
62
|
+
<p class="link"><a href="Object.html">Object</a>
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div id="includes-section" class="nav-section">
|
67
|
+
<h3>Included Modules</h3>
|
68
|
+
|
69
|
+
<ul class="link-list">
|
70
|
+
|
71
|
+
|
72
|
+
<li><span class="include">Comparable</span>
|
73
|
+
|
74
|
+
|
75
|
+
</ul>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
|
79
|
+
<!-- Method Quickref -->
|
80
|
+
<div id="method-list-section" class="nav-section">
|
81
|
+
<h3>Methods</h3>
|
82
|
+
|
83
|
+
<ul class="link-list" role="directory">
|
84
|
+
|
85
|
+
<li ><a href="#method-c-new">::new</a>
|
86
|
+
|
87
|
+
<li ><a href="#method-i-3C-3D-3E">#<=></a>
|
88
|
+
|
89
|
+
<li ><a href="#method-i-aibc">#aibc</a>
|
90
|
+
|
91
|
+
<li ><a href="#method-i-to_s">#to_s</a>
|
92
|
+
|
93
|
+
<li ><a href="#method-i-valor_energetico">#valor_energetico</a>
|
94
|
+
|
95
|
+
</ul>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
</nav>
|
100
|
+
|
101
|
+
<main role="main" aria-labelledby="class-Alimento_">
|
102
|
+
<h1 id="class-Alimento_" class="class">
|
103
|
+
class Alimento_
|
104
|
+
</h1>
|
105
|
+
|
106
|
+
<section class="description">
|
107
|
+
|
108
|
+
<p>Clase <a href="Alimento.html">Alimento</a> que representa a un alimento con
|
109
|
+
el nombre y otros datos del mismo En alimento se incluye el mixin
|
110
|
+
Comparable</p>
|
111
|
+
|
112
|
+
</section>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<section class="attribute-method-details" class="method-section">
|
126
|
+
<header>
|
127
|
+
<h3>Attributes</h3>
|
128
|
+
</header>
|
129
|
+
|
130
|
+
|
131
|
+
<div id="attribute-i-datos" class="method-detail">
|
132
|
+
<div class="method-heading attribute-method-heading">
|
133
|
+
<span class="method-name">datos</span><span
|
134
|
+
class="attribute-access-type">[RW]</span>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<div class="method-description">
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div id="attribute-i-fats" class="method-detail">
|
145
|
+
<div class="method-heading attribute-method-heading">
|
146
|
+
<span class="method-name">fats</span><span
|
147
|
+
class="attribute-access-type">[R]</span>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<div class="method-description">
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</div>
|
155
|
+
</div>
|
156
|
+
|
157
|
+
<div id="attribute-i-glucids" class="method-detail">
|
158
|
+
<div class="method-heading attribute-method-heading">
|
159
|
+
<span class="method-name">glucids</span><span
|
160
|
+
class="attribute-access-type">[R]</span>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<div class="method-description">
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div id="attribute-i-name" class="method-detail">
|
171
|
+
<div class="method-heading attribute-method-heading">
|
172
|
+
<span class="method-name">name</span><span
|
173
|
+
class="attribute-access-type">[R]</span>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
<div class="method-description">
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div id="attribute-i-proteins" class="method-detail">
|
184
|
+
<div class="method-heading attribute-method-heading">
|
185
|
+
<span class="method-name">proteins</span><span
|
186
|
+
class="attribute-access-type">[R]</span>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div class="method-description">
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</div>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
</section>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
201
|
+
<header>
|
202
|
+
<h3>Public Class Methods</h3>
|
203
|
+
</header>
|
204
|
+
|
205
|
+
|
206
|
+
<div id="method-c-new" class="method-detail ">
|
207
|
+
|
208
|
+
<div class="method-heading">
|
209
|
+
<span class="method-name">new</span><span
|
210
|
+
class="method-args">(name, proteins, glucids, fats)</span>
|
211
|
+
|
212
|
+
<span class="method-click-advice">click to toggle source</span>
|
213
|
+
|
214
|
+
</div>
|
215
|
+
|
216
|
+
|
217
|
+
<div class="method-description">
|
218
|
+
|
219
|
+
<p>Se asignan el nombre, las proteinas, los glucidos y las grasas</p>
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
<div class="method-source-code" id="new-source">
|
225
|
+
<pre><span class="ruby-comment"># File lib/alimento/alimento_.rb, line 20</span>
|
226
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">proteins</span>, <span class="ruby-identifier">glucids</span>, <span class="ruby-identifier">fats</span>)
|
227
|
+
<span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
|
228
|
+
<span class="ruby-ivar">@proteins</span> = <span class="ruby-identifier">proteins</span>
|
229
|
+
<span class="ruby-ivar">@glucids</span> = <span class="ruby-identifier">glucids</span>
|
230
|
+
<span class="ruby-ivar">@fats</span> = <span class="ruby-identifier">fats</span>
|
231
|
+
<span class="ruby-keyword">end</span></pre>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
</div>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
</div>
|
240
|
+
|
241
|
+
|
242
|
+
</section>
|
243
|
+
|
244
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
245
|
+
<header>
|
246
|
+
<h3>Public Instance Methods</h3>
|
247
|
+
</header>
|
248
|
+
|
249
|
+
|
250
|
+
<div id="method-i-3C-3D-3E" class="method-detail ">
|
251
|
+
|
252
|
+
<div class="method-heading">
|
253
|
+
<span class="method-name"><=></span><span
|
254
|
+
class="method-args">(another)</span>
|
255
|
+
|
256
|
+
<span class="method-click-advice">click to toggle source</span>
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
|
263
|
+
<p>Se define para incluir el mixin comparable Se toma como valor para la
|
264
|
+
comparación el valor energético</p>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<div class="method-source-code" id="3C-3D-3E-source">
|
270
|
+
<pre><span class="ruby-comment"># File lib/alimento/alimento_.rb, line 38</span>
|
271
|
+
<span class="ruby-keyword">def</span> <span class="ruby-operator"><=></span> (<span class="ruby-identifier">another</span>)
|
272
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">another</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Alimento_</span>
|
273
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">valor_energetico</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">another</span>.<span class="ruby-identifier">valor_energetico</span>
|
274
|
+
<span class="ruby-keyword">end</span></pre>
|
275
|
+
</div>
|
276
|
+
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
</div>
|
283
|
+
|
284
|
+
|
285
|
+
<div id="method-i-aibc" class="method-detail ">
|
286
|
+
|
287
|
+
<div class="method-heading">
|
288
|
+
<span class="method-name">aibc</span><span
|
289
|
+
class="method-args">(indice)</span>
|
290
|
+
|
291
|
+
<span class="method-click-advice">click to toggle source</span>
|
292
|
+
|
293
|
+
</div>
|
294
|
+
|
295
|
+
|
296
|
+
<div class="method-description">
|
297
|
+
|
298
|
+
<p>Devuelve el valor del AIBC de un alimento para un individuo concreto</p>
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
<div class="method-source-code" id="aibc-source">
|
304
|
+
<pre><span class="ruby-comment"># File lib/alimento/alimento_.rb, line 43</span>
|
305
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">aibc</span>(<span class="ruby-identifier">indice</span>)
|
306
|
+
<span class="ruby-identifier">vector</span> = []
|
307
|
+
<span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>][<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>].<span class="ruby-identifier">length</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>].<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>][<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>].<span class="ruby-identifier">length</span><span class="ruby-operator">-</span><span class="ruby-value">2</span>]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">gi</span>, <span class="ruby-identifier">gi_1</span> <span class="ruby-operator">|</span>
|
308
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">gi</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>][<span class="ruby-value">0</span>]
|
309
|
+
<span class="ruby-identifier">vector</span> <span class="ruby-operator"><<</span> <span class="ruby-value">0.0</span>
|
310
|
+
<span class="ruby-keyword">else</span>
|
311
|
+
<span class="ruby-identifier">vector</span> <span class="ruby-operator"><<</span> (((<span class="ruby-identifier">gi</span><span class="ruby-operator">-</span><span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>][<span class="ruby-value">0</span>])<span class="ruby-operator">+</span>(<span class="ruby-identifier">gi_1</span><span class="ruby-operator">-</span><span class="ruby-identifier">datos</span>[<span class="ruby-identifier">indice</span>][<span class="ruby-value">0</span>]))<span class="ruby-operator">/</span><span class="ruby-value">2</span>)<span class="ruby-operator">*</span><span class="ruby-value">5</span>
|
312
|
+
<span class="ruby-keyword">end</span>
|
313
|
+
<span class="ruby-keyword">end</span>
|
314
|
+
|
315
|
+
<span class="ruby-identifier">vector</span>.<span class="ruby-identifier">reduce</span>(<span class="ruby-value">:+</span>)
|
316
|
+
<span class="ruby-keyword">end</span></pre>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
</div>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
</div>
|
325
|
+
|
326
|
+
|
327
|
+
<div id="method-i-to_s" class="method-detail ">
|
328
|
+
|
329
|
+
<div class="method-heading">
|
330
|
+
<span class="method-name">to_s</span><span
|
331
|
+
class="method-args">()</span>
|
332
|
+
|
333
|
+
<span class="method-click-advice">click to toggle source</span>
|
334
|
+
|
335
|
+
</div>
|
336
|
+
|
337
|
+
|
338
|
+
<div class="method-description">
|
339
|
+
|
340
|
+
<p>Formatea la salida a texto</p>
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
<div class="method-source-code" id="to_s-source">
|
346
|
+
<pre><span class="ruby-comment"># File lib/alimento/alimento_.rb, line 27</span>
|
347
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_s</span>
|
348
|
+
<span class="ruby-identifier">string</span> = (<span class="ruby-node">"#{@name}\tproteinas:#{@proteins}\tglúcidos:#{@glucids}\tlípidos:#{@fats}"</span>)
|
349
|
+
<span class="ruby-comment"># puts string</span>
|
350
|
+
<span class="ruby-comment"># return string</span>
|
351
|
+
<span class="ruby-keyword">end</span></pre>
|
352
|
+
</div>
|
353
|
+
|
354
|
+
</div>
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
</div>
|
360
|
+
|
361
|
+
|
362
|
+
<div id="method-i-valor_energetico" class="method-detail ">
|
363
|
+
|
364
|
+
<div class="method-heading">
|
365
|
+
<span class="method-name">valor_energetico</span><span
|
366
|
+
class="method-args">()</span>
|
367
|
+
|
368
|
+
<span class="method-click-advice">click to toggle source</span>
|
369
|
+
|
370
|
+
</div>
|
371
|
+
|
372
|
+
|
373
|
+
<div class="method-description">
|
374
|
+
|
375
|
+
<p>Devuelve el valor energético</p>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
<div class="method-source-code" id="valor_energetico-source">
|
381
|
+
<pre><span class="ruby-comment"># File lib/alimento/alimento_.rb, line 33</span>
|
382
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">valor_energetico</span>
|
383
|
+
<span class="ruby-identifier">v_e</span> = (<span class="ruby-ivar">@proteins</span><span class="ruby-operator">*</span><span class="ruby-value">4</span>)<span class="ruby-operator">+</span>(<span class="ruby-ivar">@glucids</span><span class="ruby-operator">*</span><span class="ruby-value">4</span>)<span class="ruby-operator">+</span>(<span class="ruby-ivar">@fats</span><span class="ruby-operator">*</span><span class="ruby-value">9</span>)
|
384
|
+
<span class="ruby-keyword">end</span></pre>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
394
|
+
|
395
|
+
</section>
|
396
|
+
|
397
|
+
</section>
|
398
|
+
</main>
|
399
|
+
|
400
|
+
|
401
|
+
<footer id="validator-badges" role="contentinfo">
|
402
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
403
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
404
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
405
|
+
</footer>
|
406
|
+
|