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

Version Path
metric_fu-4.11.3 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.11.2 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.11.1 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.11.0 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.10.0 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.9.0 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.8.0 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.7.4 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.7.3 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.7.2 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.7.1 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.7.0 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.6.0 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.5.2 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.5.1 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.4.4 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.4.3 lib/metric_fu/metrics/saikuro/parsing_element.rb
metric_fu-4.4.2 lib/metric_fu/metrics/saikuro/parsing_element.rb