Class: EpnApi::Paper
- Inherits:
-
Object
- Object
- EpnApi::Paper
- Defined in:
- lib/epn_api/paper.rb
Instance Attribute Summary collapse
-
#annualqp ⇒ Object
Returns the value of attribute annualqp.
-
#energy ⇒ Object
Returns the value of attribute energy.
-
#grade ⇒ Object
Returns the value of attribute grade.
-
#greenhouse_gas ⇒ Object
Returns the value of attribute greenhouse_gas.
-
#name ⇒ Object
Returns the value of attribute name.
-
#recycledcontent ⇒ Object
Returns the value of attribute recycledcontent.
-
#solid_waste ⇒ Object
Returns the value of attribute solid_waste.
-
#trees ⇒ Object
Returns the value of attribute trees.
-
#water ⇒ Object
Returns the value of attribute water.
Instance Method Summary collapse
- #get_name(grade) ⇒ Object
-
#initialize(args) ⇒ Paper
constructor
A new instance of Paper.
- #initialize_paper_hash ⇒ Object
- #to_return_hash ⇒ Object
- #unit_check ⇒ Object
-
#update_via_epn ⇒ Object
PUSH THIS PROCESS TO THE APP FROM THE WRAPPER, LET RAILS COMPARE def compare(existing_paper) new_paper_string = self.object_id_strip_from_string existing_paper_string = existing_paper.object_id_strip_from_string if (new_paper_string == existing_paper_string) return false else return self end end.
Constructor Details
#initialize(args) ⇒ Paper
Returns a new instance of Paper.
6 7 8 9 10 11 12 13 14 |
# File 'lib/epn_api/paper.rb', line 6 def initialize(args) self.grade = args[:grade] or raise "Paper needs Grade" self.recycledcontent = args[:recycled_percent] or raise "Paper needs Recycled Percent" self.name = args[:name] || get_name( args[:grade] ) self.annualqp= {"amount" => 100000, "qpunits" => "pounds"} %w(trees water energy solid_waste greenhouse_gas).each do |column| self.send("#{column}=", args[column.to_sym]) if args[column.to_sym] end end |
Instance Attribute Details
#annualqp ⇒ Object
Returns the value of attribute annualqp.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def annualqp @annualqp end |
#energy ⇒ Object
Returns the value of attribute energy.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def energy @energy end |
#grade ⇒ Object
Returns the value of attribute grade.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def grade @grade end |
#greenhouse_gas ⇒ Object
Returns the value of attribute greenhouse_gas.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def greenhouse_gas @greenhouse_gas end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def name @name end |
#recycledcontent ⇒ Object
Returns the value of attribute recycledcontent.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def recycledcontent @recycledcontent end |
#solid_waste ⇒ Object
Returns the value of attribute solid_waste.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def solid_waste @solid_waste end |
#trees ⇒ Object
Returns the value of attribute trees.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def trees @trees end |
#water ⇒ Object
Returns the value of attribute water.
4 5 6 |
# File 'lib/epn_api/paper.rb', line 4 def water @water end |
Instance Method Details
#get_name(grade) ⇒ Object
16 17 18 19 |
# File 'lib/epn_api/paper.rb', line 16 def get_name(grade) paper_name_hash = self.initialize_paper_hash paper_name_hash[grade] end |
#initialize_paper_hash ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/epn_api/paper.rb', line 21 def initialize_paper_hash paper_name_hash = { 1 => "Uncoated Freesheet (e.g. copy paper)" , 2 => "Coated Freesheet (e.g. high-end catalog)" , 3 => "Uncoated Groundwood (e.g. newsprint)" , 4 => "Coated Groundwood (e.g. catalog, magazine)" , 5 => "Supercalendered (e.g. newspaper inserts)" , 6 => "Corrugated: Unbleached" , 7 => "Corrugated: Semi-bleached" , 8 => "Corrugated: Bleached" , 9 => "Paperboard: Solid Bleached Sulfate (SBS)" , 10 => "Paperboard: Coated Unbleached Kraft (CUK)" , 11 => "Paperboard: Uncoated Bleached Kraft" , 12 => "Paperboard: Uncoated Unbleached Kraft" , 13 => "Paperboard: Coated Recycled Board (CRB)" , } end |
#to_return_hash ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/epn_api/paper.rb', line 71 def to_return_hash return_hash = Hash.new %w(grade recycledcontent name trees water energy solid_waste greenhouse_gas).each do |key| return_hash.store( key, self.send("#{key}")) end return return_hash end |
#unit_check ⇒ Object
39 40 41 42 |
# File 'lib/epn_api/paper.rb', line 39 def unit_check raise "incorrect units" if self.annualqp != {"amount" => 100000, "qpunits" => "pounds"} return self.annualqp["amount"] end |
#update_via_epn ⇒ Object
PUSH THIS PROCESS TO THE APP FROM THE WRAPPER, LET RAILS COMPARE def compare(existing_paper)
new_paper_string = self.object_id_strip_from_string
existing_paper_string = existing_paper.object_id_strip_from_string
if (new_paper_string == existing_paper_string)
return false
else
return self
end
end
65 66 67 68 69 |
# File 'lib/epn_api/paper.rb', line 65 def update_via_epn api_doc = EpnApi::ApiDoc.new api_doc.epn_response!( self ) self.to_return_hash end |