class BadASS::Sale
Base class containing a Bad Dragon sale and it's attributes.
Attributes
description[R]
@return [String] the description of the sale
end_date[R]
@return [Date] the end date of the sale
image[R]
@return [String] the image URL of the sale
start_date[R]
@return [Date] the start date of the sale
title[R]
@return [String] the title of the sale
Public Class Methods
new(sale_hash)
click to toggle source
Create a Sale
object using a hash from the API. @param [Hash]
# File lib/badass/sale.rb, line 5 def initialize(sale_hash) @title = sale_hash['title'] @description = JSON.parse(sale_hash['content'])['blocks'].map { |x| x['text'] }.join("\n") @image = sale_hash['image']['url'] @start_date = Date.rfc3339(sale_hash['startDate']) rescue nil @end_date = Date.rfc3339(sale_hash['endDate']) rescue nil end