P06 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/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/P06.gemspec +42 -0
- data/README.md +5 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Alimento.html +871 -0
- data/docs/Alimento_concreto.html +459 -0
- data/docs/Array.html +316 -0
- data/docs/List.html +1135 -0
- data/docs/Nodo.html +410 -0
- data/docs/P06.html +117 -0
- data/docs/_index.html +156 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +79 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +79 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +299 -0
- data/docs/top-level-namespace.html +112 -0
- data/lib/P06.rb +23 -0
- data/lib/P06/DSL.rb +168 -0
- data/lib/P06/alimento.rb +53 -0
- data/lib/P06/alimento_concreto.rb +64 -0
- data/lib/P06/list.rb +162 -0
- data/lib/P06/version.rb +3 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9ea312299beda111e6c1bd73012b3177e63e5af
|
4
|
+
data.tar.gz: fa8c5428472118a628afdcee1c80cc05c168f838
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 413c6635602b2242d39042416c3f3607156f4ed0b736b0c89aac107ebd469f37d32f048ec5f0d66865dc888bc039fd3c5ab918a0a40805343a2600caf389aa99
|
7
|
+
data.tar.gz: 1d59e51ada57c25f3eeebe41aca62f2c641e7b8c4a59c23f49ee4db9ec65002936fd9b4ead19903635359a840454a31313859b878382dee98255da8672eda377
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at alu0100972603@ull.edu.es. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
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/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Juan Pablo Claros Romero
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/P06.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "P06/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "P06"
|
8
|
+
spec.version = P06::VERSION
|
9
|
+
spec.authors = ["Juan Pablo Claros Romero"]
|
10
|
+
spec.email = ["alu0100972603@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Practica 6}
|
13
|
+
spec.description = %q{Desarrollo Dirigido por Pruebas}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs.
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "guard"
|
39
|
+
spec.add_development_dependency "guard-rspec"
|
40
|
+
spec.add_development_dependency "guard-bundler"
|
41
|
+
spec.add_development_dependency "coveralls"
|
42
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# **Título: Desarrollo Dirigido por Pruebas**
|
2
|
+
**Nombre:** Juan Pablo Claros Romero (alu0100972603@ull.edu.es)
|
3
|
+
**Práctica:** 11
|
4
|
+
|
5
|
+
**Descripción:** En la siguiente práctica vamos a diseñar e implementar un DSL. Vamos a crear nuestro plato Harvard el cual está compuesto por vegetales o frutas, cereales y proteínas.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "P06"
|
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,871 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Alimento
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Alimento";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index (A)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Alimento</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Alimento
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Alimento</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/P06/alimento.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>Esta clase permite representar a un alimento con sus porteinas, glucidos y
|
106
|
+
grasas correspondientes. Tambien se puede sacar las calorias de los
|
107
|
+
alimentos con las proteinas, glucidos y grasas.</p>
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div class="tags">
|
113
|
+
|
114
|
+
|
115
|
+
</div><div id="subclasses">
|
116
|
+
<h2>Direct Known Subclasses</h2>
|
117
|
+
<p class="children"><span class='object_link'><a href="Alimento_concreto.html" title="Alimento_concreto (class)">Alimento_concreto</a></span></p>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
124
|
+
<ul class="summary">
|
125
|
+
|
126
|
+
<li class="public ">
|
127
|
+
<span class="summary_signature">
|
128
|
+
|
129
|
+
<a href="#glucidos-instance_method" title="#glucidos (instance method)">#<strong>glucidos</strong> ⇒ Object </a>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
</span>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
<span class="note title readonly">readonly</span>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<span class="summary_desc"><div class='inline'>
|
149
|
+
<p>Returns the value of attribute glucidos.</p>
|
150
|
+
</div></span>
|
151
|
+
|
152
|
+
</li>
|
153
|
+
|
154
|
+
|
155
|
+
<li class="public ">
|
156
|
+
<span class="summary_signature">
|
157
|
+
|
158
|
+
<a href="#grasas-instance_method" title="#grasas (instance method)">#<strong>grasas</strong> ⇒ Object </a>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
</span>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<span class="note title readonly">readonly</span>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<span class="summary_desc"><div class='inline'>
|
178
|
+
<p>Returns the value of attribute grasas.</p>
|
179
|
+
</div></span>
|
180
|
+
|
181
|
+
</li>
|
182
|
+
|
183
|
+
|
184
|
+
<li class="public ">
|
185
|
+
<span class="summary_signature">
|
186
|
+
|
187
|
+
<a href="#nombre-instance_method" title="#nombre (instance method)">#<strong>nombre</strong> ⇒ Object </a>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</span>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
<span class="note title readonly">readonly</span>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
<span class="summary_desc"><div class='inline'>
|
207
|
+
<p>Returns the value of attribute nombre.</p>
|
208
|
+
</div></span>
|
209
|
+
|
210
|
+
</li>
|
211
|
+
|
212
|
+
|
213
|
+
<li class="public ">
|
214
|
+
<span class="summary_signature">
|
215
|
+
|
216
|
+
<a href="#proteinas-instance_method" title="#proteinas (instance method)">#<strong>proteinas</strong> ⇒ Object </a>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
</span>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
<span class="note title readonly">readonly</span>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<span class="summary_desc"><div class='inline'>
|
236
|
+
<p>Returns the value of attribute proteinas.</p>
|
237
|
+
</div></span>
|
238
|
+
|
239
|
+
</li>
|
240
|
+
|
241
|
+
|
242
|
+
</ul>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
<h2>
|
249
|
+
Instance Method Summary
|
250
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
251
|
+
</h2>
|
252
|
+
|
253
|
+
<ul class="summary">
|
254
|
+
|
255
|
+
<li class="public ">
|
256
|
+
<span class="summary_signature">
|
257
|
+
|
258
|
+
<a href="#AIBC-instance_method" title="#AIBC (instance method)">#<strong>AIBC</strong> ⇒ Object </a>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
</span>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
<span class="summary_desc"><div class='inline'>
|
273
|
+
<p>Este metodo me calcula el AIBC.</p>
|
274
|
+
</div></span>
|
275
|
+
|
276
|
+
</li>
|
277
|
+
|
278
|
+
|
279
|
+
<li class="public ">
|
280
|
+
<span class="summary_signature">
|
281
|
+
|
282
|
+
<a href="#calorias-instance_method" title="#calorias (instance method)">#<strong>calorias</strong> ⇒ Object </a>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
</span>
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
<span class="summary_desc"><div class='inline'>
|
297
|
+
<p>Este metodo calcula las calorias del alimento según las proteinas, los
|
298
|
+
glucidos y las grasas del alimento.</p>
|
299
|
+
</div></span>
|
300
|
+
|
301
|
+
</li>
|
302
|
+
|
303
|
+
|
304
|
+
<li class="public ">
|
305
|
+
<span class="summary_signature">
|
306
|
+
|
307
|
+
<a href="#formateado-instance_method" title="#formateado (instance method)">#<strong>formateado</strong> ⇒ Object </a>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
</span>
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<span class="summary_desc"><div class='inline'>
|
322
|
+
<p>Este metodo muestra al alimento formateado.</p>
|
323
|
+
</div></span>
|
324
|
+
|
325
|
+
</li>
|
326
|
+
|
327
|
+
|
328
|
+
<li class="public ">
|
329
|
+
<span class="summary_signature">
|
330
|
+
|
331
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(nombre, proteinas, glucidos, grasas, individuos) ⇒ Alimento </a>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
</span>
|
336
|
+
|
337
|
+
|
338
|
+
<span class="note title constructor">constructor</span>
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
<span class="summary_desc"><div class='inline'>
|
348
|
+
<p>Se asigna el nombre del alimento, las proteinas, los glucidos y las
|
349
|
+
grasas.</p>
|
350
|
+
</div></span>
|
351
|
+
|
352
|
+
</li>
|
353
|
+
|
354
|
+
|
355
|
+
<li class="public ">
|
356
|
+
<span class="summary_signature">
|
357
|
+
|
358
|
+
<a href="#neg-instance_method" title="#neg (instance method)">#<strong>neg</strong>(pos, gluc) ⇒ Object </a>
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
</span>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
<span class="summary_desc"><div class='inline'>
|
373
|
+
<p>Este metodo lo que hace es devolverme el valor correspondiente dependiendo
|
374
|
+
de la posicion en la que me encuentre en el vector, esto lo hago para que
|
375
|
+
no me acceda a la posicion -1.</p>
|
376
|
+
</div></span>
|
377
|
+
|
378
|
+
</li>
|
379
|
+
|
380
|
+
|
381
|
+
<li class="public ">
|
382
|
+
<span class="summary_signature">
|
383
|
+
|
384
|
+
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong> ⇒ Object </a>
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
</span>
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
<span class="summary_desc"><div class='inline'>
|
399
|
+
<p>Este es el metodo to_s que muestra al alimento por pantalla.</p>
|
400
|
+
</div></span>
|
401
|
+
|
402
|
+
</li>
|
403
|
+
|
404
|
+
|
405
|
+
</ul>
|
406
|
+
|
407
|
+
|
408
|
+
<div id="constructor_details" class="method_details_list">
|
409
|
+
<h2>Constructor Details</h2>
|
410
|
+
|
411
|
+
<div class="method_details first">
|
412
|
+
<h3 class="signature first" id="initialize-instance_method">
|
413
|
+
|
414
|
+
#<strong>initialize</strong>(nombre, proteinas, glucidos, grasas, individuos) ⇒ <tt><span class='object_link'><a href="" title="Alimento (class)">Alimento</a></span></tt>
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
</h3><div class="docstring">
|
421
|
+
<div class="discussion">
|
422
|
+
|
423
|
+
<p>Se asigna el nombre del alimento, las proteinas, los glucidos y las
|
424
|
+
grasas.</p>
|
425
|
+
|
426
|
+
|
427
|
+
</div>
|
428
|
+
</div>
|
429
|
+
<div class="tags">
|
430
|
+
|
431
|
+
|
432
|
+
</div><table class="source_code">
|
433
|
+
<tr>
|
434
|
+
<td>
|
435
|
+
<pre class="lines">
|
436
|
+
|
437
|
+
|
438
|
+
13
|
439
|
+
14
|
440
|
+
15
|
441
|
+
16
|
442
|
+
17
|
443
|
+
18
|
444
|
+
19
|
445
|
+
20</pre>
|
446
|
+
</td>
|
447
|
+
<td>
|
448
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 13</span>
|
449
|
+
|
450
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_nombre'>nombre</span><span class='comma'>,</span><span class='id identifier rubyid_proteinas'>proteinas</span><span class='comma'>,</span><span class='id identifier rubyid_glucidos'>glucidos</span><span class='comma'>,</span><span class='id identifier rubyid_grasas'>grasas</span><span class='comma'>,</span><span class='id identifier rubyid_individuos'>individuos</span><span class='rparen'>)</span>
|
451
|
+
<span class='ivar'>@nombre</span> <span class='op'>=</span> <span class='id identifier rubyid_nombre'>nombre</span>
|
452
|
+
<span class='ivar'>@proteinas</span> <span class='op'>=</span> <span class='id identifier rubyid_proteinas'>proteinas</span>
|
453
|
+
<span class='ivar'>@glucidos</span> <span class='op'>=</span> <span class='id identifier rubyid_glucidos'>glucidos</span>
|
454
|
+
<span class='ivar'>@grasas</span> <span class='op'>=</span> <span class='id identifier rubyid_grasas'>grasas</span>
|
455
|
+
<span class='ivar'>@cal</span>
|
456
|
+
<span class='ivar'>@individuos</span> <span class='op'>=</span> <span class='id identifier rubyid_individuos'>individuos</span>
|
457
|
+
<span class='kw'>end</span></pre>
|
458
|
+
</td>
|
459
|
+
</tr>
|
460
|
+
</table>
|
461
|
+
</div>
|
462
|
+
|
463
|
+
</div>
|
464
|
+
|
465
|
+
<div id="instance_attr_details" class="attr_details">
|
466
|
+
<h2>Instance Attribute Details</h2>
|
467
|
+
|
468
|
+
|
469
|
+
<span id=""></span>
|
470
|
+
<div class="method_details first">
|
471
|
+
<h3 class="signature first" id="glucidos-instance_method">
|
472
|
+
|
473
|
+
#<strong>glucidos</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
</h3><div class="docstring">
|
480
|
+
<div class="discussion">
|
481
|
+
|
482
|
+
<p>Returns the value of attribute glucidos</p>
|
483
|
+
|
484
|
+
|
485
|
+
</div>
|
486
|
+
</div>
|
487
|
+
<div class="tags">
|
488
|
+
|
489
|
+
|
490
|
+
</div><table class="source_code">
|
491
|
+
<tr>
|
492
|
+
<td>
|
493
|
+
<pre class="lines">
|
494
|
+
|
495
|
+
|
496
|
+
9
|
497
|
+
10
|
498
|
+
11</pre>
|
499
|
+
</td>
|
500
|
+
<td>
|
501
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 9</span>
|
502
|
+
|
503
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_glucidos'>glucidos</span>
|
504
|
+
<span class='ivar'>@glucidos</span>
|
505
|
+
<span class='kw'>end</span></pre>
|
506
|
+
</td>
|
507
|
+
</tr>
|
508
|
+
</table>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
|
512
|
+
<span id=""></span>
|
513
|
+
<div class="method_details ">
|
514
|
+
<h3 class="signature " id="grasas-instance_method">
|
515
|
+
|
516
|
+
#<strong>grasas</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
</h3><div class="docstring">
|
523
|
+
<div class="discussion">
|
524
|
+
|
525
|
+
<p>Returns the value of attribute grasas</p>
|
526
|
+
|
527
|
+
|
528
|
+
</div>
|
529
|
+
</div>
|
530
|
+
<div class="tags">
|
531
|
+
|
532
|
+
|
533
|
+
</div><table class="source_code">
|
534
|
+
<tr>
|
535
|
+
<td>
|
536
|
+
<pre class="lines">
|
537
|
+
|
538
|
+
|
539
|
+
9
|
540
|
+
10
|
541
|
+
11</pre>
|
542
|
+
</td>
|
543
|
+
<td>
|
544
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 9</span>
|
545
|
+
|
546
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_grasas'>grasas</span>
|
547
|
+
<span class='ivar'>@grasas</span>
|
548
|
+
<span class='kw'>end</span></pre>
|
549
|
+
</td>
|
550
|
+
</tr>
|
551
|
+
</table>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
|
555
|
+
<span id=""></span>
|
556
|
+
<div class="method_details ">
|
557
|
+
<h3 class="signature " id="nombre-instance_method">
|
558
|
+
|
559
|
+
#<strong>nombre</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
</h3><div class="docstring">
|
566
|
+
<div class="discussion">
|
567
|
+
|
568
|
+
<p>Returns the value of attribute nombre</p>
|
569
|
+
|
570
|
+
|
571
|
+
</div>
|
572
|
+
</div>
|
573
|
+
<div class="tags">
|
574
|
+
|
575
|
+
|
576
|
+
</div><table class="source_code">
|
577
|
+
<tr>
|
578
|
+
<td>
|
579
|
+
<pre class="lines">
|
580
|
+
|
581
|
+
|
582
|
+
9
|
583
|
+
10
|
584
|
+
11</pre>
|
585
|
+
</td>
|
586
|
+
<td>
|
587
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 9</span>
|
588
|
+
|
589
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_nombre'>nombre</span>
|
590
|
+
<span class='ivar'>@nombre</span>
|
591
|
+
<span class='kw'>end</span></pre>
|
592
|
+
</td>
|
593
|
+
</tr>
|
594
|
+
</table>
|
595
|
+
</div>
|
596
|
+
|
597
|
+
|
598
|
+
<span id=""></span>
|
599
|
+
<div class="method_details ">
|
600
|
+
<h3 class="signature " id="proteinas-instance_method">
|
601
|
+
|
602
|
+
#<strong>proteinas</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
</h3><div class="docstring">
|
609
|
+
<div class="discussion">
|
610
|
+
|
611
|
+
<p>Returns the value of attribute proteinas</p>
|
612
|
+
|
613
|
+
|
614
|
+
</div>
|
615
|
+
</div>
|
616
|
+
<div class="tags">
|
617
|
+
|
618
|
+
|
619
|
+
</div><table class="source_code">
|
620
|
+
<tr>
|
621
|
+
<td>
|
622
|
+
<pre class="lines">
|
623
|
+
|
624
|
+
|
625
|
+
9
|
626
|
+
10
|
627
|
+
11</pre>
|
628
|
+
</td>
|
629
|
+
<td>
|
630
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 9</span>
|
631
|
+
|
632
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_proteinas'>proteinas</span>
|
633
|
+
<span class='ivar'>@proteinas</span>
|
634
|
+
<span class='kw'>end</span></pre>
|
635
|
+
</td>
|
636
|
+
</tr>
|
637
|
+
</table>
|
638
|
+
</div>
|
639
|
+
|
640
|
+
</div>
|
641
|
+
|
642
|
+
|
643
|
+
<div id="instance_method_details" class="method_details_list">
|
644
|
+
<h2>Instance Method Details</h2>
|
645
|
+
|
646
|
+
|
647
|
+
<div class="method_details first">
|
648
|
+
<h3 class="signature first" id="AIBC-instance_method">
|
649
|
+
|
650
|
+
#<strong>AIBC</strong> ⇒ <tt>Object</tt>
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
</h3><div class="docstring">
|
657
|
+
<div class="discussion">
|
658
|
+
|
659
|
+
<p>Este metodo me calcula el AIBC. Se ha aplicado la programacion funcional.</p>
|
660
|
+
|
661
|
+
|
662
|
+
</div>
|
663
|
+
</div>
|
664
|
+
<div class="tags">
|
665
|
+
|
666
|
+
|
667
|
+
</div><table class="source_code">
|
668
|
+
<tr>
|
669
|
+
<td>
|
670
|
+
<pre class="lines">
|
671
|
+
|
672
|
+
|
673
|
+
50
|
674
|
+
51
|
675
|
+
52</pre>
|
676
|
+
</td>
|
677
|
+
<td>
|
678
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 50</span>
|
679
|
+
|
680
|
+
<span class='kw'>def</span> <span class='const'>AIBC</span>
|
681
|
+
<span class='ivar'>@individuos</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_g'>g</span><span class='op'>=</span><span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='semicolon'>;</span> <span class='id identifier rubyid_pos'>pos</span><span class='op'>=</span><span class='op'>-</span><span class='int'>1</span><span class='semicolon'>;</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_j'>j</span><span class='op'>|</span> <span class='id identifier rubyid_prev'>prev</span><span class='op'>=</span><span class='id identifier rubyid_neg'>neg</span><span class='lparen'>(</span><span class='id identifier rubyid_pos'>pos</span><span class='comma'>,</span><span class='id identifier rubyid_i'>i</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='id identifier rubyid_pos'>pos</span><span class='op'>=</span><span class='id identifier rubyid_pos'>pos</span><span class='op'>+</span><span class='int'>1</span><span class='semicolon'>;</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_j'>j</span><span class='op'>-</span><span class='id identifier rubyid_g'>g</span><span class='rparen'>)</span><span class='op'>+</span><span class='lparen'>(</span><span class='id identifier rubyid_prev'>prev</span><span class='op'>-</span><span class='id identifier rubyid_g'>g</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='op'>*</span><span class='float'>2.5</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='symbol'>:+</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
682
|
+
<span class='kw'>end</span></pre>
|
683
|
+
</td>
|
684
|
+
</tr>
|
685
|
+
</table>
|
686
|
+
</div>
|
687
|
+
|
688
|
+
<div class="method_details ">
|
689
|
+
<h3 class="signature " id="calorias-instance_method">
|
690
|
+
|
691
|
+
#<strong>calorias</strong> ⇒ <tt>Object</tt>
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
</h3><div class="docstring">
|
698
|
+
<div class="discussion">
|
699
|
+
|
700
|
+
<p>Este metodo calcula las calorias del alimento según las proteinas, los
|
701
|
+
glucidos y las grasas del alimento.</p>
|
702
|
+
|
703
|
+
|
704
|
+
</div>
|
705
|
+
</div>
|
706
|
+
<div class="tags">
|
707
|
+
|
708
|
+
|
709
|
+
</div><table class="source_code">
|
710
|
+
<tr>
|
711
|
+
<td>
|
712
|
+
<pre class="lines">
|
713
|
+
|
714
|
+
|
715
|
+
37
|
716
|
+
38
|
717
|
+
39</pre>
|
718
|
+
</td>
|
719
|
+
<td>
|
720
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 37</span>
|
721
|
+
|
722
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_calorias'>calorias</span>
|
723
|
+
<span class='ivar'>@cal</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='int'>4</span><span class='op'>*</span><span class='ivar'>@proteinas</span><span class='rparen'>)</span><span class='op'>+</span><span class='lparen'>(</span><span class='int'>4</span><span class='op'>*</span><span class='ivar'>@glucidos</span><span class='rparen'>)</span><span class='op'>+</span><span class='lparen'>(</span><span class='int'>9</span><span class='op'>*</span><span class='ivar'>@grasas</span><span class='rparen'>)</span>
|
724
|
+
<span class='kw'>end</span></pre>
|
725
|
+
</td>
|
726
|
+
</tr>
|
727
|
+
</table>
|
728
|
+
</div>
|
729
|
+
|
730
|
+
<div class="method_details ">
|
731
|
+
<h3 class="signature " id="formateado-instance_method">
|
732
|
+
|
733
|
+
#<strong>formateado</strong> ⇒ <tt>Object</tt>
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
|
738
|
+
|
739
|
+
</h3><div class="docstring">
|
740
|
+
<div class="discussion">
|
741
|
+
|
742
|
+
<p>Este metodo muestra al alimento formateado.</p>
|
743
|
+
|
744
|
+
|
745
|
+
</div>
|
746
|
+
</div>
|
747
|
+
<div class="tags">
|
748
|
+
|
749
|
+
|
750
|
+
</div><table class="source_code">
|
751
|
+
<tr>
|
752
|
+
<td>
|
753
|
+
<pre class="lines">
|
754
|
+
|
755
|
+
|
756
|
+
29
|
757
|
+
30
|
758
|
+
31
|
759
|
+
32</pre>
|
760
|
+
</td>
|
761
|
+
<td>
|
762
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 29</span>
|
763
|
+
|
764
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_formateado'>formateado</span>
|
765
|
+
<span class='id identifier rubyid_print'>print</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Nombre: </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@nombre</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Proteínas: </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@proteinas</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Glúcidos: </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@glucidos</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Grasas: </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@grasas</span>
|
766
|
+
<span class='id identifier rubyid_puts'>puts</span>
|
767
|
+
<span class='kw'>end</span></pre>
|
768
|
+
</td>
|
769
|
+
</tr>
|
770
|
+
</table>
|
771
|
+
</div>
|
772
|
+
|
773
|
+
<div class="method_details ">
|
774
|
+
<h3 class="signature " id="neg-instance_method">
|
775
|
+
|
776
|
+
#<strong>neg</strong>(pos, gluc) ⇒ <tt>Object</tt>
|
777
|
+
|
778
|
+
|
779
|
+
|
780
|
+
|
781
|
+
|
782
|
+
</h3><div class="docstring">
|
783
|
+
<div class="discussion">
|
784
|
+
|
785
|
+
<p>Este metodo lo que hace es devolverme el valor correspondiente dependiendo
|
786
|
+
de la posicion en la que me encuentre en el vector, esto lo hago para que
|
787
|
+
no me acceda a la posicion -1.</p>
|
788
|
+
|
789
|
+
|
790
|
+
</div>
|
791
|
+
</div>
|
792
|
+
<div class="tags">
|
793
|
+
|
794
|
+
|
795
|
+
</div><table class="source_code">
|
796
|
+
<tr>
|
797
|
+
<td>
|
798
|
+
<pre class="lines">
|
799
|
+
|
800
|
+
|
801
|
+
44
|
802
|
+
45
|
803
|
+
46</pre>
|
804
|
+
</td>
|
805
|
+
<td>
|
806
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 44</span>
|
807
|
+
|
808
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_neg'>neg</span><span class='lparen'>(</span><span class='id identifier rubyid_pos'>pos</span><span class='comma'>,</span><span class='id identifier rubyid_gluc'>gluc</span><span class='rparen'>)</span>
|
809
|
+
<span class='id identifier rubyid_pos'>pos</span> <span class='op'><</span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_gluc'>gluc</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_gluc'>gluc</span><span class='lbracket'>[</span><span class='id identifier rubyid_pos'>pos</span><span class='rbracket'>]</span>
|
810
|
+
<span class='kw'>end</span></pre>
|
811
|
+
</td>
|
812
|
+
</tr>
|
813
|
+
</table>
|
814
|
+
</div>
|
815
|
+
|
816
|
+
<div class="method_details ">
|
817
|
+
<h3 class="signature " id="to_s-instance_method">
|
818
|
+
|
819
|
+
#<strong>to_s</strong> ⇒ <tt>Object</tt>
|
820
|
+
|
821
|
+
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
</h3><div class="docstring">
|
826
|
+
<div class="discussion">
|
827
|
+
|
828
|
+
<p>Este es el metodo to_s que muestra al alimento por pantalla.</p>
|
829
|
+
|
830
|
+
|
831
|
+
</div>
|
832
|
+
</div>
|
833
|
+
<div class="tags">
|
834
|
+
|
835
|
+
|
836
|
+
</div><table class="source_code">
|
837
|
+
<tr>
|
838
|
+
<td>
|
839
|
+
<pre class="lines">
|
840
|
+
|
841
|
+
|
842
|
+
23
|
843
|
+
24
|
844
|
+
25
|
845
|
+
26</pre>
|
846
|
+
</td>
|
847
|
+
<td>
|
848
|
+
<pre class="code"><span class="info file"># File 'lib/P06/alimento.rb', line 23</span>
|
849
|
+
|
850
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
851
|
+
<span class='id identifier rubyid_print'>print</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>El alimento </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@nombre</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> tiene </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@proteinas</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> gramos de proteínas, </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@glucidos</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> gramos de glúcidos y </span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='ivar'>@grasas</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> gramos de grasas</span><span class='tstring_end'>"</span></span>
|
852
|
+
<span class='id identifier rubyid_puts'>puts</span>
|
853
|
+
<span class='kw'>end</span></pre>
|
854
|
+
</td>
|
855
|
+
</tr>
|
856
|
+
</table>
|
857
|
+
</div>
|
858
|
+
|
859
|
+
</div>
|
860
|
+
|
861
|
+
</div>
|
862
|
+
|
863
|
+
<div id="footer">
|
864
|
+
Generated on Tue Nov 28 18:13:07 2017 by
|
865
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
866
|
+
0.9.9 (ruby-2.3.0).
|
867
|
+
</div>
|
868
|
+
|
869
|
+
</div>
|
870
|
+
</body>
|
871
|
+
</html>
|