Class: Riml::ClassDefinitionNode
- Inherits:
-
Struct
- Object
- Struct
- Riml::ClassDefinitionNode
- Includes:
- Visitable
- Defined in:
- lib/riml/nodes.rb
Constant Summary collapse
- FUNCTIONS =
lambda {|expr| DefNode === expr}
- DEFAULT_SCOPE_MODIFIER =
's:'
Constants included from Visitable
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, #parser_info, #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
-
#imported? ⇒ Boolean
This if for the AST_Rewriter, checking if a class is an ‘ImportedClass` or not without resorting to type checking.
-
#initialize ⇒ ClassDefinitionNode
constructor
A new instance of ClassDefinitionNode.
- #private_function_names ⇒ Object
- #superclass? ⇒ Boolean
Methods included from Visitable
#accept, #force_newline_if_child_call_node?, #location_info
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
Constructor Details
#initialize ⇒ ClassDefinitionNode
Returns a new instance of ClassDefinitionNode.
961 962 963 964 965 966 967 968 |
# File 'lib/riml/nodes.rb', line 961 def initialize(*) super unless scope_modifier self.scope_modifier = DEFAULT_SCOPE_MODIFIER end # registered with ClassMap @registered_state = false end |
Instance Attribute Details
#expressions ⇒ Object
Returns the value of attribute expressions
955 956 957 |
# File 'lib/riml/nodes.rb', line 955 def expressions @expressions end |
#name ⇒ Object
Returns the value of attribute name
955 956 957 |
# File 'lib/riml/nodes.rb', line 955 def name @name end |
#scope_modifier ⇒ Object
Returns the value of attribute scope_modifier
955 956 957 |
# File 'lib/riml/nodes.rb', line 955 def scope_modifier @scope_modifier end |
#superclass_name ⇒ Object Also known as: superclass_full_name
Returns the value of attribute superclass_name
955 956 957 |
# File 'lib/riml/nodes.rb', line 955 def superclass_name @superclass_name end |
Instance Method Details
#children ⇒ Object
1023 1024 1025 |
# File 'lib/riml/nodes.rb', line 1023 def children [expressions] end |
#constructor ⇒ Object Also known as: constructor?
986 987 988 989 990 991 992 993 994 995 996 997 |
# File 'lib/riml/nodes.rb', line 986 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
1011 1012 1013 |
# File 'lib/riml/nodes.rb', line 1011 def constructor_full_name "#{scope_modifier}#{name}Constructor" end |
#constructor_name ⇒ Object
1007 1008 1009 |
# File 'lib/riml/nodes.rb', line 1007 def constructor_name "#{name}Constructor" end |
#constructor_obj_name ⇒ Object
1015 1016 1017 |
# File 'lib/riml/nodes.rb', line 1015 def constructor_obj_name name[0, 1].downcase + name[1..-1] + "Obj" end |
#find_function(scope_modifier, name) ⇒ Object Also known as: has_function?
1000 1001 1002 1003 1004 |
# File 'lib/riml/nodes.rb', line 1000 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
980 981 982 |
# File 'lib/riml/nodes.rb', line 980 def full_name scope_modifier + name end |
#imported? ⇒ Boolean
This if for the AST_Rewriter, checking if a class is an ‘ImportedClass` or not without resorting to type checking.
976 977 978 |
# File 'lib/riml/nodes.rb', line 976 def imported? false end |
#private_function_names ⇒ Object
1019 1020 1021 |
# File 'lib/riml/nodes.rb', line 1019 def private_function_names @private_function_names ||= [] end |
#superclass? ⇒ Boolean
970 971 972 |
# File 'lib/riml/nodes.rb', line 970 def superclass? not superclass_name.nil? end |