Class: Danger::Violation
- Inherits:
-
Object
- Object
- Danger::Violation
- Defined in:
- lib/danger/danger_core/messages/violation.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
-
#message ⇒ Object
Returns the value of attribute message.
-
#sticky ⇒ Object
Returns the value of attribute sticky.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(message, sticky, file = nil, line = nil) ⇒ Violation
constructor
A new instance of Violation.
-
#inline? ⇒ Boolean
Returns true if is a file or line, false otherwise.
- #to_s ⇒ Object
Constructor Details
#initialize(message, sticky, file = nil, line = nil) ⇒ Violation
Returns a new instance of Violation.
5 6 7 8 9 10 |
# File 'lib/danger/danger_core/messages/violation.rb', line 5 def initialize(, sticky, file = nil, line = nil) self. = self.sticky = sticky self.file = file self.line = line end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/danger/danger_core/messages/violation.rb', line 3 def file @file end |
#line ⇒ Object
Returns the value of attribute line.
3 4 5 |
# File 'lib/danger/danger_core/messages/violation.rb', line 3 def line @line end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/danger/danger_core/messages/violation.rb', line 3 def @message end |
#sticky ⇒ Object
Returns the value of attribute sticky.
3 4 5 |
# File 'lib/danger/danger_core/messages/violation.rb', line 3 def sticky @sticky end |
Instance Method Details
#==(other) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/danger/danger_core/messages/violation.rb', line 12 def ==(other) return false if other.nil? return false unless other.kind_of? self.class other. == && other.sticky == sticky && other.file == file && other.line == line end |
#eql?(other) ⇒ Boolean
31 32 33 |
# File 'lib/danger/danger_core/messages/violation.rb', line 31 def eql?(other) return self == other end |
#hash ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/danger/danger_core/messages/violation.rb', line 22 def hash h = 1 h = h * 31 + .hash h = h * 13 + sticky.hash h = h * 17 + file.hash h = h * 17 + line.hash h end |
#inline? ⇒ Boolean
Returns true if is a file or line, false otherwise
36 37 38 |
# File 'lib/danger/danger_core/messages/violation.rb', line 36 def inline? file || line end |
#to_s ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/danger/danger_core/messages/violation.rb', line 40 def to_s extra = [] extra << "sticky: #{sticky}" extra << "file: #{file}" if file extra << "line: #{line}" if line "Violation #{} { #{extra.join ', '.freeze} }" end |