Class: EnvImpact
Instance Attribute Summary collapse
-
#ch_g ⇒ Object
Returns the value of attribute ch_g.
-
#gei ⇒ Object
Returns the value of attribute gei.
-
#lp_g ⇒ Object
Returns the value of attribute lp_g.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pr_g ⇒ Object
Returns the value of attribute pr_g.
-
#terrain ⇒ Object
Returns the value of attribute terrain.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #e_value ⇒ Object
-
#initialize(name, pr_g, ch_g, lp_g, gei, terrain) ⇒ EnvImpact
constructor
A new instance of EnvImpact.
- #n_value ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, pr_g, ch_g, lp_g, gei, terrain) ⇒ EnvImpact
Returns a new instance of EnvImpact.
10 11 12 13 14 |
# File 'lib/EnvImpact.rb', line 10 def initialize(name, pr_g, ch_g, lp_g , gei, terrain) @name = name @pr_g, @ch_g, @lp_g = pr_g, ch_g, lp_g @gei, @terrain = gei, terrain end |
Instance Attribute Details
#ch_g ⇒ Object
Returns the value of attribute ch_g.
9 10 11 |
# File 'lib/EnvImpact.rb', line 9 def ch_g @ch_g end |
#gei ⇒ Object
Returns the value of attribute gei.
9 10 11 |
# File 'lib/EnvImpact.rb', line 9 def gei @gei end |
#lp_g ⇒ Object
Returns the value of attribute lp_g.
9 10 11 |
# File 'lib/EnvImpact.rb', line 9 def lp_g @lp_g end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/EnvImpact.rb', line 9 def name @name end |
#pr_g ⇒ Object
Returns the value of attribute pr_g.
9 10 11 |
# File 'lib/EnvImpact.rb', line 9 def pr_g @pr_g end |
#terrain ⇒ Object
Returns the value of attribute terrain.
9 10 11 |
# File 'lib/EnvImpact.rb', line 9 def terrain @terrain end |
Instance Method Details
#<=>(other) ⇒ Object
28 29 30 31 32 |
# File 'lib/EnvImpact.rb', line 28 def <=>(other) return nil unless other.instance_of? EnvImpact n_value + e_value <=> other.n_value + other.e_value end |
#e_value ⇒ Object
24 25 26 |
# File 'lib/EnvImpact.rb', line 24 def e_value (gei + terrain) end |
#n_value ⇒ Object
20 21 22 |
# File 'lib/EnvImpact.rb', line 20 def n_value (@pr_g*4 + @ch_g*4 + lp_g*9) end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/EnvImpact.rb', line 16 def to_s "#{name} =>| Proteinas/g: #{pr_g} | Carbohidratos/g: #{ch_g} | Lipidos/g: #{lp_g} | GEI: #{gei} | m²/año: #{terrain}" end |