Sha256: caf22420d46f880d1f12f06679f1618b6a40367b711021fe31ca07aace3c2f3a

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

require 'turnip/node/base'
require 'turnip/node/tag'

module Turnip
  module Node
    #
    # @note Example metadata generated by Gherkin
    #
    #     {
    #       type: :Examples,
    #       tags: [], # Array of Tag
    #       location: { line: 10, column: 3 },
    #       keyword: "Examples",
    #       name: "Example Description",
    #       tableHeader: {},
    #       tableBody: {}
    #     }
    #
    class Example < Base
      include HasTags

      def keyword
        @raw[:keyword]
      end

      def name
        @raw[:name]
      end

      def description
        @raw[:description]
      end

      #
      # @note
      #
      #   Examples:
      #   | monster | hp |
      #   | slime   | 10 | => [ 'monster', 'hp' ]
      #   | daemon  | 70 |
      #
      # @return [Array]
      #
      def header
        @header ||= @raw[:table_header][:cells].map { |c| c[:value] }
      end

      #
      # @note
      #
      #   Examples:
      #   | monster | hp |
      #   | slime   | 10 | => [ ['slime', '10'], ['daemon', '70'] ]
      #   | daemon  | 70 |
      #
      # @return [Array]
      #
      def rows
        @rows ||= @raw[:table_body].map do |row|
          row[:cells].map { |c| c[:value] }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
turnip-4.3.0 lib/turnip/node/example.rb
turnip-4.2.0 lib/turnip/node/example.rb
turnip-4.1.0 lib/turnip/node/example.rb
turnip-4.0.1 lib/turnip/node/example.rb
turnip-4.0.0 lib/turnip/node/example.rb