Sha256: 249190f9871a0f17f4c0107f860096b55344b5ba492b940286c4e74fe001e849

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module JLDrill

    # A container to hold the status of each kind of drill for the item.
    class ItemStatus
        
        attr_reader :statuses, :item

        def initialize(item)
            @item = item
            @statuses = {}
        end

        def add(status)
            @statuses[status.name] = status
        end

        def assign(itemStatus)
            itemStatus.statuses.each_value do |status|
                newStatus = status.clone
                newStatus.item = @item
                add(status.clone)
            end
        end

        def select(name)
            return @statuses[name]
        end

        def parse(part)
            parsed = false
            statuses = @statuses.values
            i = 0
            while (i < statuses.size) && (!parsed)
                parsed = statuses[i].parse(part)
                i += 1
            end
            return parsed
        end

        def to_s
            retVal = ""
            @statuses.each_value do |status|
                retVal += status.to_s
            end
            return retVal
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.5.1.7 lib/jldrill/model/ItemStatus.rb