class RbGCCXML::Class

Represents a <Class> node.

Public Instance Methods

constants(name = nil, &block) click to toggle source

Find all constants under this class. See RbGCCXML::Node#namespaces

# File lib/rbgccxml/nodes/class.rb, line 66
def constants(name = nil, &block)
  NodeCache.find_children_of_type(self, "Variable", name)
end
constructors() click to toggle source

Find all the constructors for this class.

# File lib/rbgccxml/nodes/class.rb, line 16
def constructors
  NodeCache.find_children_of_type(self, "Constructor")
end
destructor() click to toggle source

Find the destructor for this class. To tell if a destructor is gcc-generated or not, check the ‘artificial’ attribute:

class_node.destructor.artificial?
# File lib/rbgccxml/nodes/class.rb, line 26
def destructor
  NodeCache.find_children_of_type(self, "Destructor")[0]
end
methods(name = nil) click to toggle source

Find all methods for this class. See RbGCCXML::Node#namespaces

# File lib/rbgccxml/nodes/class.rb, line 56
def methods(name = nil)
  NodeCache.find_children_of_type(self, "Method", name)
end
namespaces(name = nil) click to toggle source

Disabled: Classes cannot have nested namespaces

# File lib/rbgccxml/nodes/class.rb, line 6
def namespaces(name = nil)
  raise NotQueryableException.new("Cannot query for Namespaces while in a Class")
end
pure_virtual?() click to toggle source

Is this class pure virtual?

# File lib/rbgccxml/nodes/class.rb, line 11
def pure_virtual?
  attributes["abstract"] ? attributes["abstract"] == "1" : false
end
superclass(access_type = nil) click to toggle source

Find the superclass for this class. By default, this will find the superclass of any access type, pass in the type of access you’re looking for if you want specific types (e.g. public, private, protected).

If there is more than one superclass to this class, this method will only return the first superclass. # If you know or expect there to be multiple superclasses, use superclasses instead

# File lib/rbgccxml/nodes/class.rb, line 38
def superclass(access_type = nil)
  found = superclasses(access_type)
  found.empty? ? nil : found[0]
end
superclasses(access_type = nil) click to toggle source

Like superclass above, this will find all superclasses for this class. Functions the same as superclass except this method always returns a QueryResult

# File lib/rbgccxml/nodes/class.rb, line 45
def superclasses(access_type = nil)
  QueryResult.new(
    [
      NodeCache.find_children_of_type(self, "Base").select do |base|
        access_type.nil? ? true : base.send("#{access_type}?")
      end
    ].flatten.map {|base| base.cpp_type }
  )
end
variables(name = nil, &block) click to toggle source

Find all instance variables for this class. See RbGCCXML::Node#namespaces

# File lib/rbgccxml/nodes/class.rb, line 61
def variables(name = nil, &block)
  NodeCache.find_children_of_type(self, "Field", name)
end