class PackList::Category
Attributes
description[RW]
items[R]
name[RW]
Public Class Methods
new(name, description=nil)
click to toggle source
# File lib/packlist/model.rb, line 93 def initialize(name, description=nil) @name, @description = name, description @items = [] end
Public Instance Methods
base_weight()
click to toggle source
# File lib/packlist/model.rb, line 116 def base_weight items = @items.reject {|item| item.worn? || item.consumable? } items.collect {|item| item.total_weight}.reduce(Weight::ZERO, :+) end
consumable_weight()
click to toggle source
# File lib/packlist/model.rb, line 111 def consumable_weight items = @items.select {|item| item.consumable? } items.collect {|item| item.total_weight}.reduce(Weight::ZERO, :+) end
item_count()
click to toggle source
# File lib/packlist/model.rb, line 125 def item_count @items.length end
total_pack_weight()
click to toggle source
# File lib/packlist/model.rb, line 102 def total_pack_weight base_weight + consumable_weight end
total_quantity()
click to toggle source
# File lib/packlist/model.rb, line 121 def total_quantity @items.collect {|item| item.quantity}.reduce(0, :+) end
total_weight()
click to toggle source
# File lib/packlist/model.rb, line 98 def total_weight @items.collect {|item| item.total_weight}.reduce(Weight::ZERO, :+) end
worn_weight()
click to toggle source
# File lib/packlist/model.rb, line 106 def worn_weight items = @items.select {|item| item.worn? } items.collect {|item| item.total_weight}.reduce(Weight::ZERO, :+) end