Sha256: 81bd2408f6bd6391f8bc79b038ec2fd68b3f308b21ba4688526029356a2d12cf

Contents?: true

Size: 892 Bytes

Versions: 31

Compression:

Stored size: 892 Bytes

Contents

module HammerCLI
  module Help
    class AbstractItem
      INDENT_STEP = 2

      attr_reader :id, :richtext
      attr_accessor :definition

      def initialize(options = {})
        @id = options[:id]
        @indentation = options[:indentation]
        @richtext = options[:richtext] || false
      end

      def build_string
        raise NotImplementedError
      end

      def self.indent(content, indentation = nil)
        indentation ||= ' ' * INDENT_STEP
        content = content.split("\n") unless content.is_a? Array
        content.map do |line|
          (indentation + line).rstrip
        end.join("\n")
      end

      protected

      def build_definition(content)
        raise NotImplementedError
      end

      def indent(content, indentation = nil)
        indentation ||= @indentation
        self.class.indent(content, indentation)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hammer_cli-3.13.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.12.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.10.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.9.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.8.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.7.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.5.1 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.6.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.5.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.4.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.3.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.2.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.1.1 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.0.2 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.1.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.0.1 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-3.0.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-2.5.1 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-2.5.0 lib/hammer_cli/help/definition/abstract_item.rb
hammer_cli-2.3.1 lib/hammer_cli/help/definition/abstract_item.rb