Sha256: 4258b2cf280e9b084a67ffca318b90ccad4825af031c76703ed284b3f1ef0b9a

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 Bytes

Contents

require 'turnip/node/base'

module Turnip
  module Node
    #
    # @note Location metadata generated by Gherkin
    #
    #     {
    #       type: :Tag,
    #       location: { line: 10, column: 3 },
    #       name: '@tag'
    #     }
    #
    class Tag < Base
      def name
        @name ||= @raw[:name].gsub(/^@/, '')
      end
    end

    module HasTags
      #
      # @return [Array] Array of Tag
      #
      def tags
        @tags ||= @raw[:tags].map do |tag|
          Tag.new(tag)
        end
      end

      #
      # Convert for hash to be used in RSpec
      #
      # @return  [Hash]
      #
      def metadata_hash
        Hash[tags.map { |t| [t.name.to_sym, true] }]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turnip-3.0.0.pre.beta.2 lib/turnip/node/tag.rb