class StatModule::Stat

Attributes

statVersion[R]

Public Class Methods

new(process, hash = nil) click to toggle source
Calls superclass method StatModule::JSONable::new
# File lib/stat.rb, line 18
def initialize(process, hash = nil)
  @finding_print_index = 0
  @findings = []

  if hash.is_a? Hash
    super(hash)
    return
  end

  raise TypeException unless process.is_a?(StatModule::Process)
  @statVersion = '1.0.0'
  @process = process
end

Public Instance Methods

findings() click to toggle source
# File lib/stat.rb, line 41
def findings
  @findings
end
findings=(findings) click to toggle source
# File lib/stat.rb, line 32
def findings=(findings)
  raise TypeException unless findings.is_a?(Array)
  findings.each { |item|
    raise TypeException unless item.is_a?(StatModule::Finding)
    raise DuplicateElementException if @findings.include?(item)
    @findings.push(item)
  }
end
print_finding() click to toggle source
print_header() click to toggle source
process() click to toggle source
# File lib/stat.rb, line 50
def process
  @process
end
process=(process) click to toggle source
# File lib/stat.rb, line 45
def process=(process)
  raise TypeException unless process.is_a?(StatModule::Process)
  @process = process
end
summary_print(formatted = false) click to toggle source
# File lib/stat.rb, line 91
def summary_print(formatted = false)
  errors = 0
  warnings = 0
  findings.each { |finding|
    if finding.failure
      errors += 1
    else
      warnings += 1
    end
  }
  if errors == 0 && warnings == 0
    result = "#{FORMATTING_CHECKMARK} PASSED with no warning".colorize(:green)
  elsif errors == 0
    result = "#{FORMATTING_WARNING} PASSED with #{warnings} warning".colorize(:yellow)
  elsif warnings == 0
    result = "#{FORMATTING_BALL} FAILED with #{errors} error".colorize(:red)
  else
    result = "#{FORMATTING_BALL} FAILED with #{errors} error and #{warnings} warning".colorize(:red)
  end
  if formatted
    result
  else
    result[result.index(' ') + 1..result.length]
  end
end
to_json(options = {}) click to toggle source
Calls superclass method StatModule::JSONable#to_json
# File lib/stat.rb, line 87
def to_json(options = {})
  super(['finding_print_index'])
end