Class: Blur::SuperScript

Inherits:
Object
  • Object
show all
Defined in:
library/blur/script.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.authorsObject Also known as: author

Returns the value of attribute authors.



56
57
58
# File 'library/blur/script.rb', line 56

def authors
  @authors
end

.descriptionObject

Returns the value of attribute description.



56
57
58
# File 'library/blur/script.rb', line 56

def description
  @description
end

.eventsObject

Returns the value of attribute events.



56
57
58
# File 'library/blur/script.rb', line 56

def events
  @events
end

.nameObject

Returns the value of attribute name.



56
57
58
# File 'library/blur/script.rb', line 56

def name
  @name
end

.versionObject

Returns the value of attribute version.



56
57
58
# File 'library/blur/script.rb', line 56

def version
  @version
end

Instance Attribute Details

#_client_refObject

Reference to the main client that holds the script.



123
124
125
# File 'library/blur/script.rb', line 123

def _client_ref
  @_client_ref
end

#cacheObject

Returns the value of attribute cache.



129
130
131
# File 'library/blur/script.rb', line 129

def cache
  @cache
end

#configObject

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



127
128
129
# File 'library/blur/script.rb', line 127

def config
  @config
end

Class Method Details

.Author(*authors) ⇒ Object Also known as: Authors

Sets the author.

Examples:

Author 'John Doe <[email protected]>'


62
63
64
# File 'library/blur/script.rb', line 62

def Author *authors
  @authors = authors
end

.deinitObject

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



120
# File 'library/blur/script.rb', line 120

def self.deinit; end

.Description(description) ⇒ Object

Sets the description.

Examples:

Description 'This is an example script.'


70
71
72
# File 'library/blur/script.rb', line 70

def Description description
  @description = description
end

.initObject

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



116
# File 'library/blur/script.rb', line 116

def self.init; end

.inspectObject



108
# File 'library/blur/script.rb', line 108

def inspect; %%#<SuperScript:0x#{self.object_id.to_s 16}>% end

.register!(*args) ⇒ Object

Registers events to certain functions.

Examples:

register! message: :on_message, connection_ready: :connected


86
87
88
89
90
91
92
93
94
95
96
97
98
99
# 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) ⇒ Object

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



103
104
105
# File 'library/blur/script.rb', line 103

def register_event! name, method_name = name
  (@events[name] ||= []) << method_name
end

.to_sObject



107
# File 'library/blur/script.rb', line 107

def to_s; inspect end

.Version(version) ⇒ Object

Sets the version.

Examples:

Version '1.0.0'


78
79
80
# File 'library/blur/script.rb', line 78

def Version version
  @version = version
end

Instance Method Details

#inspectObject

Gets a human-readable representation of the script.



138
139
140
141
142
143
# 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) ⇒ Object

Gets the instantiated script with name.



135
# File 'library/blur/script.rb', line 135

def script name; _client_ref.scripts[name] end

#to_sObject



145
# File 'library/blur/script.rb', line 145

def to_s; inspect end

#unloadedObject

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



132
# File 'library/blur/script.rb', line 132

def unloaded; end