Sha256: 51a63a92ffcd947137800ac409edc50fdbc5dc0f635ab52f08859d7477e78d41

Contents?: true

Size: 840 Bytes

Versions: 8

Compression:

Stored size: 840 Bytes

Contents

class ProconBypassMan::Procon::MacroRegistry
  class Macro
    attr_accessor :name, :steps

    def initialize(name: , steps: )
      self.name = name
      self.steps = steps
    end

    def next_step
      steps.shift
    end

    def finished?
      steps.empty?
    end

    def ongoing?
      !finished?
    end
  end

  PRESETS = {
    null: [],
  }

  def self.install_plugin(klass)
    if plugins[klass.name]
      raise "すでに登録済みです"
    end
    plugins[klass.name] = klass.steps
  end

  def self.load(name)
    steps = PRESETS[name] || plugins[name] || raise("unknown macro")
    Macro.new(name: name, steps: steps.dup)
  end

  def self.reset!
    ProconBypassMan::Configuration.instance.macro_plugins = {}
  end

  def self.plugins
    ProconBypassMan::Configuration.instance.macro_plugins
  end

  reset!
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
procon_bypass_man-0.1.9 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.8 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.7 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.6 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.5 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.4 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.3 lib/procon_bypass_man/procon/macro_registry.rb
procon_bypass_man-0.1.2 lib/procon_bypass_man/procon/macro_registry.rb