class Git::Cop::Reporters::Lines::Paragraph

Attributes

data[R]

Public Class Methods

new(data = {}) click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 8
def initialize data = {}
  @data = data
end

Public Instance Methods

to_s() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 12
def to_s
  %(#{label}"#{paragraph}"\n)
end

Private Instance Methods

content() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 42
def content
  data.fetch :content
end
formatted_lines() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 28
def formatted_lines
  content.split("\n").map.with_index do |line, index|
    index.zero? ? line : "#{indent}#{line}"
  end
end
indent() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 34
def indent
  " " * (label.length + 1)
end
label() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 20
def label
  "#{Line::DEFAULT_INDENT}Line #{number}: "
end
number() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 38
def number
  data.fetch :number
end
paragraph() click to toggle source
# File lib/git/cop/reporters/lines/paragraph.rb, line 24
def paragraph
  formatted_lines.join "\n"
end