Class: Roll
- Inherits:
-
Object
- Object
- Roll
- Defined in:
- lib/dim_wishlist/roll.rb
Instance Attribute Summary collapse
-
#item_id ⇒ Object
Returns the value of attribute item_id.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#perks ⇒ Object
Returns the value of attribute perks.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(item_id:, perks:, notes: nil) ⇒ Roll
constructor
A new instance of Roll.
- #key ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(item_id:, perks:, notes: nil) ⇒ Roll
Returns a new instance of Roll.
12 13 14 15 16 |
# File 'lib/dim_wishlist/roll.rb', line 12 def initialize(item_id:, perks:, notes: nil) @item_id = item_id @perks = perks @notes = notes end |
Instance Attribute Details
#item_id ⇒ Object
Returns the value of attribute item_id.
4 5 6 |
# File 'lib/dim_wishlist/roll.rb', line 4 def item_id @item_id end |
#notes ⇒ Object
Returns the value of attribute notes.
4 5 6 |
# File 'lib/dim_wishlist/roll.rb', line 4 def notes @notes end |
#perks ⇒ Object
Returns the value of attribute perks.
4 5 6 |
# File 'lib/dim_wishlist/roll.rb', line 4 def perks @perks end |
Class Method Details
.key(item_id, perks) ⇒ Object
7 8 9 |
# File 'lib/dim_wishlist/roll.rb', line 7 def key(item_id, perks) Digest::SHA2.new(512).hexdigest "#{item_id},#{perks.join(',')}" end |
Instance Method Details
#key ⇒ Object
18 19 20 |
# File 'lib/dim_wishlist/roll.rb', line 18 def key self.class.key(@item_id, @perks) end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/dim_wishlist/roll.rb', line 22 def to_s "dimwishlist:item=#{@item_id}&perks=#{perks.join(',')}#{!@notes.nil? ? "#notes:#{notes}" : ''}" end |