Sha256: 4040502b5406aa54bdad8869ce5acd6f5277f4c3c86a5e19c36a279f8584dd22

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module CucumberAnalytics

  # A class modeling an basic element of a feature.

  class FeatureElement

    include Sourceable
    include Raw
    include Nested


    # The name of the FeatureElement
    attr_accessor :name

    # The description of the FeatureElement
    attr_accessor :description


    # Creates a new FeatureElement object and, if *parsed_element* is provided,
    # populates the object.
    def initialize(parsed_element = nil)
      @name = ''
      @description =[]

      build_feature_element(parsed_element) if parsed_element
    end


    private


    def build_feature_element(parsed_element)
      populate_feature_element_name(parsed_element)
      populate_feature_element_description(parsed_element)
      populate_element_source_line(parsed_element)
      populate_raw_element(parsed_element)
    end

    def populate_feature_element_name(parsed_element)
      @name = parsed_element['name']
    end

    def populate_feature_element_description(parsed_element)
      @description = parsed_element['description'].split("\n").collect { |line| line.strip }
      @description.delete('')
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber_analytics-1.4.2 lib/cucumber_analytics/feature_element.rb
cucumber_analytics-1.4.1 lib/cucumber_analytics/feature_element.rb
cucumber_analytics-1.4.0 lib/cucumber_analytics/feature_element.rb
cucumber_analytics-1.3.0 lib/cucumber_analytics/feature_element.rb