Class: VivlioStarter::CLI::PreProcessCommands::TalkRegistry::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio_starter/cli/pre_process/talk_registry.rb

Overview

正規化結果の集合。present はファイルの実在(.talk 使用時のエラー分岐に使う)。

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(characters, display:, present:) ⇒ Registry

Returns a new instance of Registry.

Parameters:

  • characters (Array<Character>)

    正規化済みキャラクター(出現順)

  • display (TalkDisplay)

    表示設定

  • present (Boolean)

    config/talk.yml が実在したか



80
81
82
83
84
85
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 80

def initialize(characters, display:, present:)
  @characters = characters.freeze
  @by_key = characters.to_h { [it.key, it] }.freeze
  @display = display
  @present = present
end

Instance Attribute Details

#charactersObject (readonly)

Returns the value of attribute characters.



75
76
77
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 75

def characters
  @characters
end

#displayObject (readonly)

Returns the value of attribute display.



75
76
77
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 75

def display
  @display
end

Instance Method Details

#[](key) ⇒ Object



87
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 87

def [](key) = @by_key[key.to_s]

#empty?Boolean

Returns:

  • (Boolean)


90
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 90

def empty? = @characters.empty?

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


88
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 88

def key?(key) = @by_key.key?(key.to_s)

#present?Boolean

Returns:

  • (Boolean)


89
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 89

def present? = @present

#with_colorObject

色を明示指定した(有効な)キャラクターのみ(生成 CSS の対象)。



93
# File 'lib/vivlio_starter/cli/pre_process/talk_registry.rb', line 93

def with_color = @characters.select(&:color)