First time here? Check out the Help page!
1 | initial version |
This function will get all the "setters" for a specific 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
2 | No.2 Revision |
This function will get all the "setters" for a specific class where the class, e.g. class_name
argument is a string, 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
3 | No.3 Revision |
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 self.get_setters(class_name)
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
4 | No.4 Revision |
This function will get all the "setters" for a specific class, e.g. BuildingStory. The same can be done for getters, resetters, autosizers, etc.BuildingStory
.
# 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
5 | No.5 Revision |
This function will get all the "setters" for a specific class, e.g. BuildingStory. BuildingStory, without the need for instantiation. The same can be done for getters, resetters, autosizers, etc.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