class Blur::SuperScript

Attributes

author[RW]
authors[RW]
description[RW]
events[RW]
name[RW]
version[RW]
_client_ref[RW]

Reference to the main client that holds the script.

cache[RW]
config[RW]

Script-specific configuration that is read from the main configuration file.

Public Class Methods

Author(*authors) click to toggle source

Sets the author.

@example

Author 'John Doe <john.doe@example.com>'
# File library/blur/script.rb, line 62
def Author *authors
  @authors = authors
end
Also aliased as: Authors
Authors(*authors)
Alias for: Author
Description(description) click to toggle source

Sets the description.

@example

Description 'This is an example script.'
# File library/blur/script.rb, line 70
def Description description
  @description = description
end
Version(version) click to toggle source

Sets the version.

@example

Version '1.0.0'
# File library/blur/script.rb, line 78
def Version version
  @version = version
end
deinit() click to toggle source

Called right before the script is being removed from the list of superscripts.

# File library/blur/script.rb, line 120
def self.deinit; end
init() click to toggle source

Called when when the superscript has been loaded and added to the list of superscripts.

# File library/blur/script.rb, line 116
def self.init; end
inspect() click to toggle source
# File library/blur/script.rb, line 108
def inspect; %%#<SuperScript:0x#{self.object_id.to_s 16}>% end
register!(*args) click to toggle source

Registers events to certain functions.

@example

register! message: :on_message, connection_ready: :connected
# File library/blur/script.rb, line 86
def register! *args
  args.each do |events|
    case events
    when Hash
      events.each do |event, method_name|
        register_event! event, method_name
      end
    when Array
      register! *events
    when Symbol
      register_event! events
    end
  end
end
register_event!(name, method_name = name) click to toggle source

Adds the given event name and the name of the method to call once the event is emitted.

# File library/blur/script.rb, line 103
def register_event! name, method_name = name
  (@events[name] ||= []) << method_name
end
to_s() click to toggle source
# File library/blur/script.rb, line 107
def to_s; inspect end

Public Instance Methods

inspect() click to toggle source

Gets a human-readable representation of the script.

# File library/blur/script.rb, line 138
def inspect
  "#<Script(#{self.class.name.inspect}) " \
    "@author=#{self.class.author.inspect} " \
    "@version=#{self.class.version.inspect} " \
    "@description=#{self.class.description.inspect}>"
end
script(name;) click to toggle source

Gets the instantiated script with name.

# File library/blur/script.rb, line 135
def script name; _client_ref.scripts[name] end
to_s() click to toggle source
# File library/blur/script.rb, line 145
def to_s; inspect end
unloaded() click to toggle source

Called right before the instance of the script is being removed.

# File library/blur/script.rb, line 132
def unloaded; end