Revision history  [back]

This function will get all the "setters" for a specific class, e.g. BuildingStory, without the need for instantiation. The same can be done for getters, resetters, autosizers, etc. and could be adapted to simply get all the instance_methods as @Denis Bourgeois suggested.

# return an array of all set methods for specific class_name string
def get_setters(class_name)

  array = []

  instance_methods = OpenStudio::Model.const_get(class_name).instance_methods
  instance_methods.each do |instance_method|
    array << instance_method if instance_method.to_s.start_with? 'set'
  end
  array.pop(12) # remove the last 12 elements, which are general setters

  return array

end

This function will get all the "setters" for a specific class, e.g. BuildingStory, without the need for instantiation. BuildingStory. The same can be done for getters, resetters, autosizers, etc. and could be adapted to simply get all the instance_methods as @Denis Bourgeois suggested.etc.

# return an array of all set methods for specific class_name string
def get_setters(class_name)

  array = []

  instance_methods = OpenStudio::Model.const_get(class_name).instance_methods
  instance_methods.each do |instance_method|
    array << instance_method if instance_method.to_s.start_with? 'set'
  end
  array.pop(12) # remove the last 12 elements, which are general setters

  return array

end

This function will get all the "setters" for a specific class, e.g. BuildingStory. BuildingStory. The same can be done for getters, resetters, autosizers, etc.

# return an array of all set methods for specific class_name string
def get_setters(class_name)

  array = []

  instance_methods = OpenStudio::Model.const_get(class_name).instance_methods
  instance_methods.each do |instance_method|
    array << instance_method if instance_method.to_s.start_with? 'set'
  end
  array.pop(12) # remove the last 12 elements, which are general setters

  return array

end

This function will get all the "setters" for a specific class, e.g. BuildingStory. The same can be done for getters, resetters, autosizers, etc.

# return an array of all set methods for specific class_name string
def get_setters(class_name)
self.get_setters(class_name)

  array = []

  instance_methods = OpenStudio::Model.const_get(class_name).instance_methods
  instance_methods.each do |instance_method|
    array << instance_method if instance_method.to_s.start_with? 'set'
  end
  array.pop(12) # remove the last 12 elements, which are general setters

  return array

end

This function will get all the "setters" for a specific class, class where the class_name argument is a string, e.g. BuildingStory. The same can be done for getters, resetters, autosizers, etc.

# return an array of all set methods for specific class_name string
def self.get_setters(class_name)

  array = []

  instance_methods = OpenStudio::Model.const_get(class_name).instance_methods
  instance_methods.each do |instance_method|
    array << instance_method if instance_method.to_s.start_with? 'set'
  end
  array.pop(12) # remove the last 12 elements, which are general setters

  return array

end