Class: Grit::DiffLine

Inherits:
Struct
  • Object
show all
Defined in:
lib/grit/ext/diff_line.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



2
3
4
# File 'lib/grit/ext/diff_line.rb', line 2

def content
  @content
end

#diff_positionObject

Returns the value of attribute diff_position

Returns:

  • (Object)

    the current value of diff_position



2
3
4
# File 'lib/grit/ext/diff_line.rb', line 2

def diff_position
  @diff_position
end

#line_numberObject

Returns the value of attribute line_number

Returns:

  • (Object)

    the current value of line_number



2
3
4
# File 'lib/grit/ext/diff_line.rb', line 2

def line_number
  @line_number
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



2
3
4
# File 'lib/grit/ext/diff_line.rb', line 2

def status
  @status
end

Class Method Details

.status_from_char(char) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/grit/ext/diff_line.rb', line 15

def self.status_from_char(char)
  case char
  when '+' then :added
  when '-' then :removed
  when ' ' then :unchanged
  else
    nil
  end
end

Instance Method Details

#added?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/grit/ext/diff_line.rb', line 3

def added?
  status == :added
end

#removed?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/grit/ext/diff_line.rb', line 7

def removed?
  status == :removed
end

#to_sObject



25
26
27
# File 'lib/grit/ext/diff_line.rb', line 25

def to_s
  "#{char_from_status}#{content}"
end

#unchanged?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/grit/ext/diff_line.rb', line 11

def unchanged?
  status == :unchanged
end