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, #file_identifier_hash, #head_sha, #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
# 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]

  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


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

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

#complete?Boolean

Returns:

  • (Boolean)

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

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

#keyObject


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

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

#position_typeObject


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

def position_type
  "image"
end

#to_hObject


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

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