Class: Riml::ClassDefinitionNode
- Inherits:
-
Struct
- Object
- Struct
- Riml::ClassDefinitionNode
- Defined in:
- lib/nodes.rb
Constant Summary collapse
- FUNCTIONS =
lambda {|expr| DefNode === expr}
- DEFAULT_SCOPE_MODIFIER =
's:'
Constants included from Visitable
Visitable::DESCENDANT_OF_REGEX
Instance Attribute Summary collapse
-
#expressions ⇒ Object
Returns the value of attribute expressions.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scope_modifier ⇒ Object
Returns the value of attribute scope_modifier.
-
#superclass_name ⇒ Object
(also: #superclass_full_name)
Returns the value of attribute superclass_name.
Attributes included from Visitable
#compiled_output, #force_newline, #parent_node, #scope
Instance Method Summary collapse
- #children ⇒ Object
- #constructor ⇒ Object (also: #constructor?)
- #constructor_full_name ⇒ Object
- #constructor_name ⇒ Object
- #constructor_obj_name ⇒ Object
- #find_function(scope_modifier, name) ⇒ Object (also: #has_function?)
- #full_name ⇒ Object
-
#initialize ⇒ ClassDefinitionNode
constructor
A new instance of ClassDefinitionNode.
- #private_function_names ⇒ Object
- #superclass? ⇒ Boolean
Methods included from Walkable
#child_after, #child_previous_to, #each, #index_by_children, #index_by_member, #insert_after, #insert_before, #next, #previous, #remove, #replace_with
Methods included from Visitable
#accept, #method_missing, #respond_to?
Constructor Details
#initialize ⇒ ClassDefinitionNode
Returns a new instance of ClassDefinitionNode.
944 945 946 947 948 949 950 951 |
# File 'lib/nodes.rb', line 944 def initialize(*) super unless scope_modifier self.scope_modifier = DEFAULT_SCOPE_MODIFIER end # registered with ClassMap @registered_state = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Riml::Visitable
Instance Attribute Details
#expressions ⇒ Object
Returns the value of attribute expressions
937 938 939 |
# File 'lib/nodes.rb', line 937 def expressions @expressions end |
#name ⇒ Object
Returns the value of attribute name
937 938 939 |
# File 'lib/nodes.rb', line 937 def name @name end |
#scope_modifier ⇒ Object
Returns the value of attribute scope_modifier
937 938 939 |
# File 'lib/nodes.rb', line 937 def scope_modifier @scope_modifier end |
#superclass_name ⇒ Object Also known as: superclass_full_name
Returns the value of attribute superclass_name
937 938 939 |
# File 'lib/nodes.rb', line 937 def superclass_name @superclass_name end |
Instance Method Details
#children ⇒ Object
1000 1001 1002 |
# File 'lib/nodes.rb', line 1000 def children [expressions] end |
#constructor ⇒ Object Also known as: constructor?
963 964 965 966 967 968 969 970 971 972 973 974 |
# File 'lib/nodes.rb', line 963 def constructor expressions.nodes.detect do |n| next(false) unless DefNode === n && (n.name == 'initialize' || n.name == constructor_name) if n.instance_of?(DefMethodNode) Riml.warn("class #{full_name.inspect} has an initialize function declared with 'defm'. Please use 'def'.") new_node = n.to_def_node new_node.keywords = nil n.replace_with(new_node) end true end end |
#constructor_full_name ⇒ Object
988 989 990 |
# File 'lib/nodes.rb', line 988 def constructor_full_name "#{scope_modifier}#{name}Constructor" end |
#constructor_name ⇒ Object
984 985 986 |
# File 'lib/nodes.rb', line 984 def constructor_name "#{name}Constructor" end |
#constructor_obj_name ⇒ Object
992 993 994 |
# File 'lib/nodes.rb', line 992 def constructor_obj_name name[0].downcase + name[1..-1] + "Obj" end |
#find_function(scope_modifier, name) ⇒ Object Also known as: has_function?
977 978 979 980 981 |
# File 'lib/nodes.rb', line 977 def find_function(scope_modifier, name) expressions.nodes.select(&FUNCTIONS).detect do |def_node| def_node.name == name && def_node.scope_modifier == scope_modifier end end |
#full_name ⇒ Object
957 958 959 |
# File 'lib/nodes.rb', line 957 def full_name scope_modifier + name end |
#private_function_names ⇒ Object
996 997 998 |
# File 'lib/nodes.rb', line 996 def private_function_names @private_function_names ||= [] end |
#superclass? ⇒ Boolean
953 954 955 |
# File 'lib/nodes.rb', line 953 def superclass? not superclass_name.nil? end |