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, #head_sha, #ignore_whitespace_change, #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 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
#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
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
26 27 28 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 26 def complete? [x, y, width, height].all?(&:present?) end |
#key ⇒ Object
22 23 24 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 22 def key @key ||= super.push(x, y) end |
#position_type ⇒ Object
34 35 36 |
# File 'lib/gitlab/diff/formatters/image_formatter.rb', line 34 def position_type "image" end |
#to_h ⇒ Object
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 |