Sha256: 9be924abc79da3fd971b895f1fadbde2b7f8bb773d536042c8c951bd8991d0e8
Contents?: true
Size: 961 Bytes
Versions: 18
Compression:
Stored size: 961 Bytes
Contents
module MetricFu class SaikuroParsingElement TYPE_REGEX=/Type:(.*) Name/ NAME_REGEX=/Name:(.*) Complexity/ COMPLEXITY_REGEX=/Complexity:(.*) Lines/ LINES_REGEX=/Lines:(.*)/ attr_reader :complexity, :lines, :defs, :element_type attr_accessor :name def initialize(line) @line = line @element_type = line.match(TYPE_REGEX)[1].strip @name = line.match(NAME_REGEX)[1].strip @complexity = line.match(COMPLEXITY_REGEX)[1].strip @lines = line.match(LINES_REGEX)[1].strip @defs = [] end def <<(line) @defs << MetricFu::SaikuroParsingElement.new(line) end def to_h base = {:name => @name, :complexity => @complexity.to_i, :lines => @lines.to_i} unless @defs.empty? defs = @defs.map do |my_def| my_def = my_def.to_h my_def.delete(:defs) my_def end base[:defs] = defs end return base end end end
Version data entries
18 entries across 18 versions & 1 rubygems