Class: Tuxedo::CaneViolation::StyleViolation

Inherits:
Tuxedo::CaneViolation show all
Defined in:
lib/tuxedo/cane_violation/style_violation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tuxedo::CaneViolation

#violation_type, #violation_type_snake_cased

Instance Attribute Details

#char_countObject

Returns the value of attribute char_count.



5
6
7
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 5

def char_count
  @char_count
end

#file_nameObject

Returns the value of attribute file_name.



4
5
6
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 4

def file_name
  @file_name
end

#line_numberObject

Returns the value of attribute line_number.



4
5
6
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 4

def line_number
  @line_number
end

#max_char_countObject

Returns the value of attribute max_char_count.



5
6
7
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 5

def max_char_count
  @max_char_count
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 4

def message
  @message
end

#style_violation_typeObject

Returns the value of attribute style_violation_type.



5
6
7
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 5

def style_violation_type
  @style_violation_type
end

Class Method Details

.from_cane(cane_violation) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 7

def self.from_cane(cane_violation)
  violation = new

  violation.file_name   = cane_violation.file_name
  violation.line_number = cane_violation.line
  violation.message     = cane_violation.message

  if cane_violation.message.match /Line is >(\d+) characters \((\d+)\)/
    violation.style_violation_type = "LineTooLong"
    violation.max_char_count       = $1.to_i
    violation.char_count           = $2.to_i
  end

  violation
end

Instance Method Details

#descriptionObject



23
24
25
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 23

def description
  "Lines violated style requirements"
end

#to_hashObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tuxedo/cane_violation/style_violation.rb', line 27

def to_hash
  {
    :violation_type       => violation_type,
    :file_name            => file_name,
    :line                 => line,
    :style_violation_type => style_violation_type,
    :max_char_count       => max_char_count,
    :char_count           => char_count,
    :description          => description,
  }
end