Sha256: 091f1485c313f426510418aac4a807aac28ea3bd586273fbfd2b66964e24f384

Contents?: true

Size: 910 Bytes

Versions: 11

Compression:

Stored size: 910 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Reporters
      module Lines
        class Paragraph
          def initialize data = {}
            @data = data
          end

          def to_s
            %(#{label}"#{paragraph}"\n)
          end

          private

          attr_reader :data

          def label
            "#{Line::DEFAULT_INDENT}Line #{number}: "
          end

          def paragraph
            formatted_lines.join "\n"
          end

          def formatted_lines
            content.split("\n").map.with_index do |line, index|
              index.zero? ? line : "#{indent}#{line}"
            end
          end

          def indent
            " " * (label.length + 1)
          end

          def number
            data.fetch :number
          end

          def content
            data.fetch :content
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
git-lint-2.2.1 lib/git/lint/reporters/lines/paragraph.rb
git-lint-2.2.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-2.1.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-2.0.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.4.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.3.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.2.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.1.1 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.1.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.0.1 lib/git/lint/reporters/lines/paragraph.rb
git-lint-1.0.0 lib/git/lint/reporters/lines/paragraph.rb