Sha256: b59c2b12a7d830951aa68b1cb72b46b6f1724c009f7d75906cea78197dddf8af

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'turnip_formatter'
require 'turnip_formatter/renderer/html/base'
require 'turnip_formatter/renderer/html/doc_string'
require 'turnip_formatter/renderer/html/data_table'
require 'turnip/table'

module TurnipFormatter
  module Renderer
    module Html
      #
      # @resource [TurnipFormatter::Resource::Step]
      #
      class Step < Base
        delegate :text, :status

        def keyword
          @resource.keyword.strip
        end

        def argument
          @argument ||= case @resource.argument
                        when ::Turnip::Table
                          DataTable.new(@resource.argument).render
                        when String
                          DocString.new(@resource.argument).render
                        end
        end

        def extra_information
          extra_information_templates.map do |template, method|
            template.send(method, @resource)
          end.join("\n")
        end

        def has_appendix?
          !!argument or !extra_information_templates.empty?
        end

        private

        def extra_information_templates
          @extra_information_templates ||= TurnipFormatter.step_templates_for(status)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
turnip_formatter-0.8.0 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.7.2 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.7.1 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.7.0 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.1 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.0 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.0.pre.beta.7 lib/turnip_formatter/renderer/html/step.rb