Sha256: ace14792a3e3e5205efbac9aa8989a4deec3e0cca068403552d198391a7b4d55

Contents?: true

Size: 743 Bytes

Versions: 5

Compression:

Stored size: 743 Bytes

Contents

module HammerCLI
  module Help
    class Section < AbstractItem
      attr_reader :label

      def initialize(label, definition = nil, options = {})
        super(options)
        @label = label
        @richtext = options[:richtext] || false
        @id ||= label
        build_definition(definition)
      end

      def build_string
        out = StringIO.new
        out.puts heading
        out.puts indent(@definition.build_string)
        out.string
      end

      protected

      def build_definition(content)
        @definition = content || Definition.new
      end

      private

      def heading
        label = "#{@label}:"
        label = HighLine.color(label, :bold) if @richtext
        label
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hammer_cli-0.18.1 lib/hammer_cli/help/definition/section.rb
hammer_cli-0.18.0 lib/hammer_cli/help/definition/section.rb
hammer_cli-0.17.1 lib/hammer_cli/help/definition/section.rb
hammer_cli-0.17.0 lib/hammer_cli/help/definition/section.rb
hammer_cli-0.16.0 lib/hammer_cli/help/definition/section.rb