Sha256: 90273469419a8187cea293fd55c79292bc1bd0f290c25b4a72fec552f29d5b6f

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

# @author Eric Dürr
 


require "lppP6/version"

class EnvImpact
    include Comparable
    attr_accessor :name, :pr_g, :ch_g, :lp_g , :gei, :terrain
    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

    def to_s
        "#{name} =>| Proteinas/g: #{pr_g} | Carbohidratos/g: #{ch_g} | Lipidos/g: #{lp_g} | GEI: #{gei} | m²/año: #{terrain}"
    end

    def n_value
        (@pr_g*4 + @ch_g*4 + lp_g*9) 
    end

    def e_value
        (gei + terrain) 
    end

    def <=>(other)
        return nil unless other.instance_of? EnvImpact
        
        n_value + e_value <=> other.n_value + other.e_value
    end

    
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lppP6lu0101027005-1.0.0 lib/EnvImpact.rb