module Kanzen

Constants

DEFAULT_IGNORE_LIST

These are fields that, for the most part, won't be taken into consideration when calculating the percentage completed for a given model.

PS: They are ignored when a custom ignore_list is passed.

DEFAULT_PROC

This is the default proc used to determine if a given attribute is valid or not. We convert attributes to string and since nils are converted to “”, we can compare that to see if a given attribute is different from an empty string literal

VERSION

Public Instance Methods

completed?(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns true if the model and its associations are all filled.

A proc containing a comparison can also be passed in order to define if a given attribute is valid or not.

# File lib/kanzen.rb, line 30
def completed?(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).completed?
end
missing_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns hash containing a list of missing attributes. They are organized in the following the order:

your_hash = attribute_name

# File lib/kanzen.rb, line 60
def missing_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).missing_attributes
end
number_of_missing_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns the number of missing attributes

# File lib/kanzen.rb, line 70
def number_of_missing_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).number_of_missing_attributes
end
number_of_present_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns the number of present attributes

# File lib/kanzen.rb, line 65
def number_of_present_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).number_of_present_attributes
end
percentage_missing(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns a percentage value for the amount of missing attributes.

# File lib/kanzen.rb, line 36
def percentage_missing(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).percentage_missing
end
percentage_present(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns a percentage value for the amount of present attributes.

# File lib/kanzen.rb, line 42
def percentage_present(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).percentage_present
end
present_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST) click to toggle source

Returns a hash containing a list of present attributes. They are organized in the following the order:

your_hash = attribute_name

# File lib/kanzen.rb, line 51
def present_attributes(proc: DEFAULT_PROC, ignore_list: DEFAULT_IGNORE_LIST)
  kanzen_calculation(proc, ignore_list).present_attributes
end

Private Instance Methods

kanzen_calculation(proc, *ignore_list) click to toggle source
# File lib/kanzen.rb, line 76
def kanzen_calculation(proc, *ignore_list)
  Kanzen::Inspection.new(self, proc, ignore_list).completion_check
end