class CwCardUtils::ScryfallCmcData
Public: Singleton accessor for Scryfall-based CMC/type data. 日本語: Scryfall ベースの CMC/タイプ情報へのシングルトンアクセスを提供します。
Public Class Methods
Source
# File lib/cw_card_utils/scryfall_cmc_data.rb, line 186 def initialize super @data = nil @card_index = nil @found_cards = {} end
Calls superclass method
Public Instance Methods
Source
# File lib/cw_card_utils/scryfall_cmc_data.rb, line 217 def cmc_data load_data_if_needed @data end
Public: Full CMC dataset as parsed JSON array. 日本語: 解析済みの JSON 配列データ全体を返します。
How it works (EN): Lazily loads the bundled JSON once, building an in-memory hash index by card name for fast lookups. Subsequent calls reuse the cached data.
仕組み (JA): バンドルされた JSON を遅延読み込みし、カード名をキーにしたインメモリのハッシュインデックスを構築します。以降の呼び出しではキャッシュを再利用します。
@return [Array<Hash>]
Source
# File lib/cw_card_utils/scryfall_cmc_data.rb, line 198 def find_card(name) load_data_if_needed @card_index[name] || @found_cards[name] ||= linear_search(name) rescue StandardError nil end
Public: Find a card hash by name, using index or linear search. 日本語: インデックスまたは線形探索でカード名からデータを検索します。
@param name [String] @return [Hash, nil]