Sha256: e703968a924ca5b12598a261cd42d4108cb5f381aac7c6c90266d508d3e59000

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module DigimonSleuth
  class Digimon
    attr_reader :name, :digivolve, :dedigivolve

    @digimon = Hash.new

    def self.find(name)
      digimon = @digimon[name.downcase]
      raise DigimonNotFoundError, "There is no digimon with name #{name}" unless digimon
      digimon
    end

    def self.all
      return @digimon.values
    end

    def self.register(digimon)
      @digimon[digimon.name.downcase] = digimon
    end

    def initialize(name)
      @name = name
      @digivolve = Array.new
      @dedigivolve = Array.new
    end

    def add_digivolve(digimon)
      @digivolve << digimon
    end

    def add_dedigivolve(digimon)
      @dedigivolve << digimon
    end

    def inspect
      "#{name}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
digimon_sleuth-0.0.3 lib/digimon_sleuth/digimon.rb
digimon_sleuth-0.0.2 lib/digimon_sleuth/digimon.rb