Module: CodeRay::Plugin

Included in:
Encoders::Encoder, Scanners::Scanner, Styles::Style
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb

Overview

Plugin

Plugins have to include this module.

IMPORTANT: Use extend for this module.

See CodeRay::PluginHost for examples.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#plugin_idObject (readonly)

Returns the value of attribute plugin_id.



12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb', line 12

def plugin_id
  @plugin_id
end

Instance Method Details

#aliasesObject



46
47
48
49
50
51
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb', line 46

def aliases
  plugin_host.plugin_hash.inject [] do |aliases, (key, _)|
    aliases << key if plugin_host[key] == self
    aliases
  end
end

#plugin_host(host = nil) ⇒ Object

The PluginHost for this Plugin class.



39
40
41
42
43
44
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb', line 39

def plugin_host host = nil
  if host.is_a? PluginHost
    const_set :PLUGIN_HOST, host
  end
  self::PLUGIN_HOST
end

#register_for(id) ⇒ Object

Register this class for the given id.

Example:

class MyPlugin < PluginHost::BaseClass
  register_for :my_id
  ...
end

See PluginHost.register.



23
24
25
26
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb', line 23

def register_for id
  @plugin_id = id
  plugin_host.register self, id
end

#title(title = nil) ⇒ Object

Returns the title of the plugin, or sets it to the optional argument title.



30
31
32
33
34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb', line 30

def title title = nil
  if title
    @title = title.to_s
  else
    @title ||= name[/([^:]+)$/, 1]
  end
end