Sha256: 008942606230c3b116c1e62586a32e5dd91312ea64d04c1292de14f8177ac913

Contents?: true

Size: 859 Bytes

Versions: 17

Compression:

Stored size: 859 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Reporters
      module Lines
        # Reports paragraph details.
        class Paragraph
          def initialize data = {}
            @data = data
          end

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

          alias to_str to_s

          private

          attr_reader :data

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

          def paragraph = formatted_lines.join("\n")

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

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

          def number = data.fetch(:number)

          def content = data.fetch(:content)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
git-lint-5.0.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.6.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.5.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.4.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.3.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.2.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.1.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.0.1 lib/git/lint/reporters/lines/paragraph.rb
git-lint-4.0.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.3.2 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.3.1 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.3.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.2.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.1.0 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.0.2 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.0.1 lib/git/lint/reporters/lines/paragraph.rb
git-lint-3.0.0 lib/git/lint/reporters/lines/paragraph.rb