Class: Danger::Markdown

Inherits:
BaseMessage show all
Defined in:
lib/danger/danger_core/messages/markdown.rb

Instance Attribute Summary

Attributes inherited from BaseMessage

#file, #line, #message, #type

Instance Method Summary collapse

Methods inherited from BaseMessage

#cmp_nils, #compare_by_file_and_line, #eql?, #inline?

Constructor Details

#initialize(message, file = nil, line = nil) ⇒ Markdown

Returns a new instance of Markdown.



7
8
9
# File 'lib/danger/danger_core/messages/markdown.rb', line 7

def initialize(message, file = nil, line = nil)
  super(type: :markdown, message: message, file: file, line: line)
end

Instance Method Details

#<=>(other) ⇒ Object



35
36
37
38
39
# File 'lib/danger/danger_core/messages/markdown.rb', line 35

def <=>(other)
  return 1 if other.type != :markdown

  compare_by_file_and_line(other)
end

#==(other) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/danger/danger_core/messages/markdown.rb', line 11

def ==(other)
  return false if other.nil?
  return false unless other.kind_of? self.class

  other.message == message &&
    other.file == file &&
    other.line == line
end

#hashObject



20
21
22
23
24
25
# File 'lib/danger/danger_core/messages/markdown.rb', line 20

def hash
  h = 1
  h = h * 31 + message.hash
  h = h * 17 + file.hash
  h * 17 + line.hash
end

#to_sObject



27
28
29
30
31
32
33
# File 'lib/danger/danger_core/messages/markdown.rb', line 27

def to_s
  extra = []
  extra << "file: #{file}" unless file
  extra << "line: #{line}" unless line

  "Markdown #{message} { #{extra.join ', '} }"
end