Class: Sarif::Rectangle
- Inherits:
-
Object
- Object
- Sarif::Rectangle
- Defined in:
- lib/sarif/rectangle.rb
Overview
An area within an image.
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#left ⇒ Object
Returns the value of attribute left.
-
#message ⇒ Object
Returns the value of attribute message.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(top: nil, left: nil, bottom: nil, right: nil, message: nil, properties: nil) ⇒ Rectangle
constructor
A new instance of Rectangle.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(top: nil, left: nil, bottom: nil, right: nil, message: nil, properties: nil) ⇒ Rectangle
Returns a new instance of Rectangle.
8 9 10 11 12 13 14 15 |
# File 'lib/sarif/rectangle.rb', line 8 def initialize(top: nil, left: nil, bottom: nil, right: nil, message: nil, properties: nil) @top = top @left = left @bottom = bottom @right = right @message = @properties = properties end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
6 7 8 |
# File 'lib/sarif/rectangle.rb', line 6 def bottom @bottom end |
#left ⇒ Object
Returns the value of attribute left.
6 7 8 |
# File 'lib/sarif/rectangle.rb', line 6 def left @left end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/sarif/rectangle.rb', line 6 def @message end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/rectangle.rb', line 6 def properties @properties end |
#right ⇒ Object
Returns the value of attribute right.
6 7 8 |
# File 'lib/sarif/rectangle.rb', line 6 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
6 7 8 |
# File 'lib/sarif/rectangle.rb', line 6 def top @top end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
44 45 46 47 |
# File 'lib/sarif/rectangle.rb', line 44 def ==(other) return false unless other.is_a?(Rectangle) @top == other.top && @left == other.left && @bottom == other.bottom && @right == other.right && @message == other. && @properties == other.properties end |
#hash ⇒ Object
51 52 53 |
# File 'lib/sarif/rectangle.rb', line 51 def hash [@top, @left, @bottom, @right, @message, @properties].hash end |
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sarif/rectangle.rb', line 17 def to_h h = {} h["top"] = @top unless @top.nil? h["left"] = @left unless @left.nil? h["bottom"] = @bottom unless @bottom.nil? h["right"] = @right unless @right.nil? h["message"] = @message&.to_h unless @message.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
28 29 30 |
# File 'lib/sarif/rectangle.rb', line 28 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |