Class: Godot::RubyScript

Inherits:
ScriptExtension
  • Object
show all
Defined in:
lib/godot_rb/ruby_script.rb

Defined Under Namespace

Modules: Autoloads

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass = nil) ⇒ RubyScript

Returns a new instance of RubyScript.



8
9
10
11
12
# File 'lib/godot_rb/ruby_script.rb', line 8

def initialize(klass = nil)
  #TODO check type of `klass`
  klass&.const_set :RUBY_SCRIPT, self
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

The parsed class, which may be de-sync with #source_code until #_reloaded



7
8
9
# File 'lib/godot_rb/ruby_script.rb', line 7

def klass
  @klass
end

#source_codeObject

The Godot Editor pass entire source code( references)s around to enable IDE capabilities independent of the disk



15
16
17
# File 'lib/godot_rb/ruby_script.rb', line 15

def source_code
  @source_code
end

Class Method Details

.base_class_nameObject



4
# File 'lib/godot_rb/ruby_script.rb', line 4

def self.base_class_name = StringName.new 'ScriptExtension'

Instance Method Details

#_get_base_scriptObject



38
39
40
# File 'lib/godot_rb/ruby_script.rb', line 38

def _get_base_script
  klass.superclass.const_get :RUBY_SCRIPT if klass
end

#_get_global_nameObject



28
29
30
31
# File 'lib/godot_rb/ruby_script.rb', line 28

def _get_global_name
  name = klass&.name #: ::String?
  name ? StringName.new(name) : StringName.new
end

#_get_instance_base_typeObject



41
# File 'lib/godot_rb/ruby_script.rb', line 41

def _get_instance_base_type = klass ? klass.base_class_name : StringName.new

#_get_languageObject



24
25
# File 'lib/godot_rb/ruby_script.rb', line 24

def _get_language = Godot::RubyLanguage::INSTANCE
# TODO: LSP integration

#_get_source_codeObject



16
# File 'lib/godot_rb/ruby_script.rb', line 16

def _get_source_code = source_code || String.new

#_has_source_codeObject



18
# File 'lib/godot_rb/ruby_script.rb', line 18

def _has_source_code = source_code.nonzero?

#_instance_has(obj) ⇒ Object



36
# File 'lib/godot_rb/ruby_script.rb', line 36

def _instance_has(obj) = klass ? obj.instance_of?(klass) : false

#_is_toolObject

TODO: LSP integration



26
# File 'lib/godot_rb/ruby_script.rb', line 26

def _is_tool = true

#_is_validObject Also known as: _can_instantiate



32
33
34
# File 'lib/godot_rb/ruby_script.rb', line 32

def _is_valid = !!klass
# *Cannot* instantiate if the script is non-existent (it shouldn’t);
# *shouldn’t* instantiate if it’s invalid (fails static checks)

#_reload(_keep_state) ⇒ Object



20
21
22
# File 'lib/godot_rb/ruby_script.rb', line 20

def _reload(_keep_state)
  1 # TODO
end

#newObject

!
void _update_exports ( ) virtual

! Standard Reflection
Dictionary _get_constants ( ) virtual const
StringName[] _get_members ( ) virtual const
Dictionary _get_method_info ( StringName method ) virtual const
Dictionary[] _get_script_method_list ( ) virtual const
bool _has_method ( StringName method ) virtual const
bool _inherits_script ( Script script ) virtual const

! Extended Reflection
Dictionary[] _get_script_property_list ( ) virtual const
bool _has_property_default_value ( StringName property ) virtual const
Variant _get_property_default_value ( StringName property ) virtual const

Extended Reflection
Dictionary[] _get_script_signal_list ( ) virtual const
bool _has_script_signal ( StringName signal ) virtual const

LSP integration
Dictionary[] _get_documentation ( ) virtual const
int _get_member_line ( StringName member ) virtual const

TODO: Ask the Godot community for a description on placeholders and fallbacks
bool _is_placeholder_fallback_enabled ( ) virtual const
void _placeholder_erased ( void* placeholder ) virtual
GDExtensionScriptInstancePtr _placeholder_instance_create ( Object for_object ) virtual const

?
def _get_rpc_config: () -> Variant



75
76
77
78
# File 'lib/godot_rb/ruby_script.rb', line 75

def new(...)
  # Temporary workaround until script initializing finds insight
  klass.new(...).tap { _1.set_script self }
end