class IdentifyRepeatedFormulaElements
Constants
- IGNORE_TYPES
Attributes
bothered_threshold[RW]
counted_elements[RW]
references[RW]
Public Class Methods
new()
click to toggle source
# File src/simplify/identify_repeated_formula_elements.rb, line 7 def initialize @references = {} @counted_elements = {} @counted_elements.default_proc = lambda do |hash,key| hash[key] = 0 end @bothered_threshold = 20 end
Public Instance Methods
count(references)
click to toggle source
# File src/simplify/identify_repeated_formula_elements.rb, line 16 def count(references) @references = references references.each do |ref,ast| identify_repeated_formulae(ast) end return @counted_elements end
identify_repeated_formulae(ast)
click to toggle source
# File src/simplify/identify_repeated_formula_elements.rb, line 26 def identify_repeated_formulae(ast) string = ast.to_s return unless ast.is_a?(Array) return if IGNORE_TYPES.has_key?(ast.first) return if string.length < bothered_threshold @counted_elements[ast] += 1 ast.each do |a| identify_repeated_formulae(a) end end