class Kanzen::Result

Attributes

missing_attributes[RW]
number_of_missing_attributes[RW]
number_of_present_attributes[RW]
present_attributes[RW]

Public Class Methods

build_result(present_attributes, number_of_present_attributes, missing_attributes, number_of_missing_attributes) click to toggle source
# File lib/kanzen/result.rb, line 18
def self.build_result(present_attributes, number_of_present_attributes,
    missing_attributes, number_of_missing_attributes)
  Result.new(present_attributes,
             number_of_present_attributes,
             missing_attributes,
             number_of_missing_attributes)
end
new(present_attributes, number_of_present_attributes, missing_attributes, number_of_missing_attributes) click to toggle source
# File lib/kanzen/result.rb, line 8
def initialize(present_attributes,
               number_of_present_attributes,
               missing_attributes,
               number_of_missing_attributes)
  self.present_attributes = present_attributes
  self.number_of_present_attributes = number_of_present_attributes
  self.missing_attributes = missing_attributes
  self.number_of_missing_attributes = number_of_missing_attributes
end

Public Instance Methods

completed?() click to toggle source

Returns true if the model and its associations are fully filled

# File lib/kanzen/result.rb, line 41
def completed?
  number_of_missing_attributes.zero?
end
percentage_missing() click to toggle source

Returns the percentage of missing attributes

# File lib/kanzen/result.rb, line 27
def percentage_missing
  total = number_of_missing_attributes + number_of_present_attributes

  ((number_of_missing_attributes * 100) / total.to_f).round(2)
end
percentage_present() click to toggle source

Returns the percentage of present attributes

# File lib/kanzen/result.rb, line 34
def percentage_present
  total = number_of_missing_attributes + number_of_present_attributes

  ((number_of_present_attributes * 100) / total.to_f).round(2)
end