class ANN
parent with helper methods
Private Instance Methods
create_method(name, &block)
click to toggle source
define method with supplied name and block
# File lib/ann_wrapper/ann.rb, line 6 def create_method(name, &block) self.class.send(:define_method, name, &block) end
to_hash(excludes)
click to toggle source
return hash of methods and returns excluding those in excludes
# File lib/ann_wrapper/ann.rb, line 12 def to_hash(excludes) # get list of methods excluding above methods = self.class.instance_methods(false).reject {|m| excludes.include? m} # map methods and results to hash data = methods.map do |method | result = self.send(method) # convert Structs to hash if (result.is_a? Array) result.map! do |item| item.is_a?(Struct) ? item.hash : item end else result.hash! if result.is_a?(Struct) end # make hash with method name and result of call [method.to_sym, result] end # return hash Hash[data] end