Class: Gitlab::Diff::Formatters::ImageFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Gitlab::Diff::Formatters::ImageFormatter
- Defined in:
- lib/gitlab/diff/formatters/image_formatter.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Attributes inherited from BaseFormatter
#base_sha, #file_identifier_hash, #head_sha, #new_path, #old_path, #start_sha
Instance Method Summary collapse
- #==(other) ⇒ Object
- #complete? ⇒ Boolean
-
#initialize(attrs) ⇒ ImageFormatter
constructor
A new instance of ImageFormatter.
- #key ⇒ Object
- #position_type ⇒ Object
- #to_h ⇒ Object
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
#height ⇒ Object (readonly)
Returns the value of attribute height
8 9 10 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 8 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width
7 8 9 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 7 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x
9 10 11 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 9 def x @x end |
#y ⇒ Object (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
25 26 27 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 25 def complete? [x, y, width, height].all?(&:present?) end |
#key ⇒ Object
21 22 23 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 21 def key @key ||= super.push(x, y) end |
#position_type ⇒ Object
33 34 35 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 33 def position_type "image" end |
#to_h ⇒ Object
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 |