Class: Gitlab::Diff::Formatters::ImageFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/gitlab/diff/formatters/image_formatter.rb

Instance Attribute Summary collapse

Attributes inherited from BaseFormatter

#base_sha, #head_sha, #ignore_whitespace_change, #new_path, #old_path, #start_sha

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ ImageFormatter

Returns a new instance of ImageFormatter.



12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 12

def initialize(attrs)
  @x = attrs[:x]
  @y = attrs[:y]
  @width = attrs[:width]
  @height = attrs[:height]
  @ignore_whitespace_change = false

  super(attrs)
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



8
9
10
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 8

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



7
8
9
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 7

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



9
10
11
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 9

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



10
11
12
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 10

def y
  @y
end

Instance Method Details

#==(other) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 38

def ==(other)
  other.is_a?(self.class) &&
    x == other.x &&
    y == other.y &&
    width == other.width &&
    height == other.height
end

#complete?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 26

def complete?
  [x, y, width, height].all?(&:present?)
end

#keyObject



22
23
24
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 22

def key
  @key ||= super.push(x, y)
end

#position_typeObject



34
35
36
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 34

def position_type
  "image"
end

#to_hObject



30
31
32
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 30

def to_h
  super.merge(width: width, height: height, x: x, y: y)
end