Class: Tronprint::Application
- Inherits:
-
Object
- Object
- Tronprint::Application
- Includes:
- Carbon
- Defined in:
- lib/tronprint/application.rb
Overview
Tronprint::Application is the class responsible for obtaining emission estimates from CM1.
Instance Attribute Summary (collapse)
-
- (Object) brighter_planet_key
readonly
Returns the value of attribute brighter_planet_key.
-
- (Object) duration
readonly
Returns the value of attribute duration.
-
- (Object) zip_code
readonly
Returns the value of attribute zip_code.
Instance Method Summary (collapse)
- - (Object) emission_estimate(options = {})
-
- (Object) impact(options = {})
The options accepted are those accepted by Carbon#impact method.
-
- (Application) initialize(attrs = {})
constructor
Initialize using Rails' model initializer style.
Constructor Details
- (Application) initialize(attrs = {})
Initialize using Rails' model initializer style.
Tronprint::Application.new :duration => 3.0
20 21 22 23 24 |
# File 'lib/tronprint/application.rb', line 20 def initialize(attrs = {}) @duration = attrs[:duration] @zip_code = attrs[:zip_code] @brighter_planet_key = attrs[:brighter_planet_key] end |
Instance Attribute Details
- (Object) brighter_planet_key (readonly)
Returns the value of attribute brighter_planet_key
15 16 17 |
# File 'lib/tronprint/application.rb', line 15 def brighter_planet_key @brighter_planet_key end |
- (Object) duration (readonly)
Returns the value of attribute duration
15 16 17 |
# File 'lib/tronprint/application.rb', line 15 def duration @duration end |
- (Object) zip_code (readonly)
Returns the value of attribute zip_code
15 16 17 |
# File 'lib/tronprint/application.rb', line 15 def zip_code @zip_code end |
Instance Method Details
- (Object) emission_estimate(options = {})
34 35 36 37 38 |
# File 'lib/tronprint/application.rb', line 34 def emission_estimate( = {}) if response = impact() response.decisions.carbon.object.value end end |
- (Object) impact(options = {})
The options accepted are those accepted by Carbon#impact method
28 29 30 31 32 |
# File 'lib/tronprint/application.rb', line 28 def impact( = {}) if (response = impact(.merge(:key => brighter_planet_key))).success response end end |