class Riml::ClassDefinitionNode

Constants

DEFAULT_SCOPE_MODIFIER
FUNCTIONS

Public Class Methods

new(*) click to toggle source
Calls superclass method
# 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

Public Instance Methods

children() click to toggle source
# File lib/riml/nodes.rb, line 1023
def children
  [expressions]
end
constructor() click to toggle source
# 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
Also aliased as: constructor?
constructor?()
Alias for: constructor
constructor_full_name() click to toggle source
# File lib/riml/nodes.rb, line 1011
def constructor_full_name
  "#{scope_modifier}#{name}Constructor"
end
constructor_name() click to toggle source
# File lib/riml/nodes.rb, line 1007
def constructor_name
  "#{name}Constructor"
end
constructor_obj_name() click to toggle source
# 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) click to toggle source
# 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
Also aliased as: has_function?
full_name() click to toggle source
# File lib/riml/nodes.rb, line 980
def full_name
  scope_modifier + name
end
has_function?(scope_modifier, name)
Alias for: find_function
imported?() click to toggle source

This if for the AST_Rewriter, checking if a class is an ‘ImportedClass` or not without resorting to type checking.

# File lib/riml/nodes.rb, line 976
def imported?
  false
end
private_function_names() click to toggle source
# File lib/riml/nodes.rb, line 1019
def private_function_names
  @private_function_names ||= []
end
superclass?() click to toggle source
# File lib/riml/nodes.rb, line 970
def superclass?
  not superclass_name.nil?
end