Class: CouponItems

Inherits:
Array
  • Object
show all
Defined in:
lib/order_review.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from(source) ⇒ Object



76
77
78
79
80
81
# File 'lib/order_review.rb', line 76

def self.from(source)
  doc = Nokogiri::HTML(source)
  coupon_items = doc.css(".m-side_useCoupon li").map { |item| CouponItem.new(item) }

  CouponItems.new(coupon_items)
end

Instance Method Details

#to_sObject



83
84
85
86
# File 'lib/order_review.rb', line 83

def to_s
  return unless count > 0
  "\nCoupons".colorize(:green)
end