class Deckstrings::Database

@private

Public Class Methods

instance() click to toggle source
# File lib/deckstrings/deckstrings.rb, line 70
def self.instance
  @@instance ||= Database.new
end
new() click to toggle source
# File lib/deckstrings/deckstrings.rb, line 65
def initialize
  file = File.expand_path('database.json', File.dirname(__FILE__))
  @database = JSON.parse(File.read(file))
end

Public Instance Methods

cards() click to toggle source
# File lib/deckstrings/deckstrings.rb, line 74
def cards
  @cards ||= begin
    @database['cards'].map { |k, v| [k.to_i, v] }.to_h
  end
end
heroes() click to toggle source
# File lib/deckstrings/deckstrings.rb, line 80
def heroes
  @heroes ||= begin
    @database['heroes'].map { |k, v| [k.to_i, v] }.to_h
  end
end