Sha256: 8d02b49ad09721971a5116c5eed02537238081548e4a709caccee2d33df34d37

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

module Radiustar

  class ValuesCollection

    def initialize
      @collection = {}
      @revcollection = []
    end

    def add(name, id)
      @collection[name] ||= Value.new(name, id)
      @revcollection[id.to_i] ||= @collection[name]
    end

    def find_by_name(name)
      @collection[name]
    end

    def find_by_id(id)
      @revcollection[id]
    end

    def empty?
      @collection.empty?
    end

  end

  class Value
    attr_accessor :name

    def initialize(name, id)
      @name = name
      @id = id.to_i
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiustar-0.0.2 lib/radiustar/dictionary/values.rb
radiustar-0.0.1 lib/radiustar/dictionary/values.rb