Guest User

Untitled

a guest
Sep 17th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.72 KB | None | 0 0
  1. class Item
  2.   attr_reader :order, :trophy
  3.   def initialize(order, trophy)
  4.     @order    = order
  5.     @trophy   = trophy
  6.     @shipping = order.shipping_person
  7.     @address  = Address.new(@shipping)
  8.   end
  9.   def program
  10.     @trophy.program
  11.   end
  12.   def orderid
  13.     @order.id
  14.   end
  15.   def email
  16.     @order.email
  17.   end
  18.   def quantity
  19.     @trophy.quantity
  20.   end
  21.   def year
  22.     @trophy.year
  23.   end
  24.   def award
  25.     if @trophy.award.end_with? ' of the Year' # this line seems to be the problem
  26.       'Grand w/ Wreath'
  27.     else
  28.       @trophy.award
  29.     end
  30.   end
  31. end
  32.  
  33. # line if @trophy.award.end_with? ' of the Year' is giving:
  34. # item.rb:25:in `award': undefined method `end_with?' for nil:NilClass (NoMethodError)
Advertisement
Add Comment
Please, Sign In to add comment