Class: Syntaxer::FileStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/syntaxer/file_status.rb

Overview

Contain filename, status of the syntax and list of errors

Constant Summary collapse

@@error_files =
[]
@@all_files =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name, errors = []) ⇒ FileStatus

Returns a new instance of FileStatus.



11
12
13
14
15
# File 'lib/syntaxer/file_status.rb', line 11

def initialize(file_name, errors = [])
  @errors = errors
  @file_name = file_name      
  @status = @errors.empty? ? :ok : :failed 
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/syntaxer/file_status.rb', line 9

def errors
  @errors
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



9
10
11
# File 'lib/syntaxer/file_status.rb', line 9

def file_name
  @file_name
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/syntaxer/file_status.rb', line 9

def status
  @status
end

Class Method Details

.all_filesObject



28
29
30
# File 'lib/syntaxer/file_status.rb', line 28

def all_files
  @@all_files
end

.build(file_name, errors = []) ⇒ Object



18
19
20
21
22
# File 'lib/syntaxer/file_status.rb', line 18

def build(file_name, errors = [])
  file_status = new(file_name, errors)
  @@all_files << file_status
  @@error_files << file_status unless errors.empty?
end

.error_filesObject



24
25
26
# File 'lib/syntaxer/file_status.rb', line 24

def error_files
  @@error_files
end