module Plugin::GUI::Cuscadable

タブとかペインみたいにたくさん作れるパーツ

Attributes

name[RW]
plugin[R]
slug[R]

Public Class Methods

included(klass) click to toggle source
# File core/plugin/gui/cuscadable.rb, line 8
def included(klass)
  klass.instance_eval{
    private
    alias new_cuscadable new
    def new(slug, name, plugin)
      type_strict slug => Symbol, name => String, plugin => tcor(NilClass, Symbol)
      new_cuscadable(slug, name, plugin) end }
  klass.extend ExtendedCuscadable end
new(slug, name, plugin) click to toggle source
# File core/plugin/gui/cuscadable.rb, line 12
def new(slug, name, plugin)
  type_strict slug => Symbol, name => String, plugin => tcor(NilClass, Symbol)
  new_cuscadable(slug, name, plugin) end
new(slug, name, plugin_name) click to toggle source
# File core/plugin/gui/cuscadable.rb, line 17
def initialize(slug, name, plugin_name)
  @slug, @name, @plugin = slug, name.freeze, plugin_name
  @unload_hook = nil
  if plugin_name
    plugin = Plugin.instance(plugin_name)
    if plugin
      @unload_hook = plugin.onunload(&method(:destroy)) end end
  self.class.register(self) end

Public Instance Methods

next() click to toggle source

次のインスタンスを返す。このインスタンスが最後だった場合は最初に戻る

# File core/plugin/gui/cuscadable.rb, line 27
def next
  values = self.class.cuscaded.values
  instance, index = values.each_with_index.find{ |instance, index| self.equal?(instance) }
  index += 1
  index -= values.size if index >= values.size
  values[index] end
prev() click to toggle source

前のインスタンスを返す。このインスタンスが最初だった場合は最後に戻る

# File core/plugin/gui/cuscadable.rb, line 35
def prev
  values = self.class.cuscaded.values
  instance, index = values.each_with_index.find{ |instance, index| self.equal?(instance) }
  index -= 1
  index += values.size if index < 0
  values[index] end