Class: WishlistItem
- Inherits:
-
Object
- Object
- WishlistItem
- Defined in:
- lib/dim_wishlist/item.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
Returns the value of attribute info.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#rolls ⇒ Object
Returns the value of attribute rolls.
Instance Method Summary collapse
- #has_roll?(item_id, perks) ⇒ Boolean
-
#initialize(lines) ⇒ WishlistItem
constructor
rolls schema { Roll.key(item_id, perks) => [roll…] }.
- #item_ids ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(lines) ⇒ WishlistItem
rolls schema { Roll.key(item_id, perks) => [roll…] }
9 10 11 12 13 14 |
# File 'lib/dim_wishlist/item.rb', line 9 def initialize(lines) @info = [] @notes = [] @rolls = {} lines.each { |line| process(line) } end |
Instance Attribute Details
#info ⇒ Object
Returns the value of attribute info.
4 5 6 |
# File 'lib/dim_wishlist/item.rb', line 4 def info @info end |
#notes ⇒ Object
Returns the value of attribute notes.
4 5 6 |
# File 'lib/dim_wishlist/item.rb', line 4 def notes @notes end |
#rolls ⇒ Object
Returns the value of attribute rolls.
4 5 6 |
# File 'lib/dim_wishlist/item.rb', line 4 def rolls @rolls end |
Instance Method Details
#has_roll?(item_id, perks) ⇒ Boolean
20 21 22 |
# File 'lib/dim_wishlist/item.rb', line 20 def has_roll?(item_id, perks) !@rolls[Roll.key(item_id, perks)].nil? end |
#item_ids ⇒ Object
16 17 18 |
# File 'lib/dim_wishlist/item.rb', line 16 def item_ids @rolls.values.map(&:item_id).uniq end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/dim_wishlist/item.rb', line 24 def to_s ["// #{@info.join('. ')}", "// #{@notes.join('. ')}", @rolls.values.map(&:to_s), "\n"].flatten.join("\n") end |