Class: Gotta::Mod::ModBuilder
- Inherits:
-
Object
- Object
- Gotta::Mod::ModBuilder
- Defined in:
- lib/gotta/mod/mod_builder.rb
Instance Attribute Summary collapse
-
#description(desc) ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version(ver) ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #depends_on(mod_name) ⇒ Object
-
#initialize(name:, &block) ⇒ ModBuilder
constructor
A new instance of ModBuilder.
- #on(type, &block) ⇒ Object
- #watch(filter, &block) ⇒ Object
Constructor Details
#initialize(name:, &block) ⇒ ModBuilder
Returns a new instance of ModBuilder.
15 16 17 18 19 20 |
# File 'lib/gotta/mod/mod_builder.rb', line 15 def initialize(name:, &block) @name = name instance_eval(&block) Mod.hub.loaded_mods << name puts "Mod '#{name}' registered." end |
Instance Attribute Details
#description(desc) ⇒ Object (readonly)
Returns the value of attribute description.
11 12 13 |
# File 'lib/gotta/mod/mod_builder.rb', line 11 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/gotta/mod/mod_builder.rb', line 11 def name @name end |
#version(ver) ⇒ Object (readonly)
Returns the value of attribute version.
11 12 13 |
# File 'lib/gotta/mod/mod_builder.rb', line 11 def version @version end |
Class Method Details
.mod(name, &block) ⇒ Object
7 8 9 |
# File 'lib/gotta/mod/mod_builder.rb', line 7 def self.mod(name, &block) new(name: name, &block) end |
Instance Method Details
#depends_on(mod_name) ⇒ Object
30 31 32 |
# File 'lib/gotta/mod/mod_builder.rb', line 30 def depends_on(mod_name) Mod.hub.add_dependency({self.name => mod_name}) end |
#on(type, &block) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/gotta/mod/mod_builder.rb', line 34 def on(type, &block) Mod.hub.register_mod( mod_name: name, path: @filter, on: type, &block ) end |
#watch(filter, &block) ⇒ Object
43 44 45 46 |
# File 'lib/gotta/mod/mod_builder.rb', line 43 def watch(filter, &block) @filter = filter instance_eval &block end |