Class: BadASS::Sale
- Inherits:
-
Object
- Object
- BadASS::Sale
- Defined in:
- lib/badass/sale.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(sale_hash) ⇒ Sale
constructor
Create a Sale object using a hash from the API.
Constructor Details
#initialize(sale_hash) ⇒ Sale
Create a Sale object using a hash from the API.
3 4 5 6 7 8 9 |
# File 'lib/badass/sale.rb', line 3 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 |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/badass/sale.rb', line 12 def description @description end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
15 16 17 |
# File 'lib/badass/sale.rb', line 15 def end_date @end_date end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
13 14 15 |
# File 'lib/badass/sale.rb', line 13 def image @image end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
14 15 16 |
# File 'lib/badass/sale.rb', line 14 def start_date @start_date end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/badass/sale.rb', line 11 def title @title end |