lib/fertile_forest/modules/calculators.rb
#
# Calculate depth and queue as root node to append.
# @return [Hash] Calculated queue and depth.
# @return [false] Can not calculate.
#
Calculate depth and queue as root node to append.
Calculate depth and queue as root node to append .
def ff_calc_required_columns_for_appending_as_root(node)
            posted_grove = node.ff_grove.to_i
            if has_grove? && posted_grove <= 0
              return false
            end
            fill_info = {ff_depth: ROOT_DEPTH}
             calculate queue
             get max queue in grove
            last_queue = ff_get_last_queue(posted_grove)   can be nil
            if last_queue.nil?
              append_queue = 0
            elsif QUEUE_MAX_VALUE <= last_queue
               Try to scoot over pre-nodes.
              evenize_res = ff_evenize(posted_grove, nil, nil, 1)  1: append node count
               When fail to evenize, filled all id.
              if evenize_res.blank?
                 TODO: set error append.canNotScootsOver'
                return false
              end
              append_queue = evenize_res[SPROUT_VACANT_QUEUE_KEY]
            elsif QUEUE_MAX_VALUE - last_queue < QUEUE_DEFAULT_INTERVAL
              append_queue = QUEUE_MAX_VALUE
            else
              append_queue = last_queue + QUEUE_DEFAULT_INTERVAL
            end
             return value
            fill_info.merge({ff_queue: append_queue})
          end
def ff_calc_required_columns_for_appending_as_root ( node ) posted_grove = node . ff_grove . to_i if has_grove? && posted_grove <= 0 return false end fill_info = { ff_depth : ROOT_DEPTH } last_queue = ff_get_last_queue ( posted_grove ) if last_queue . nil? append_queue = 0 elsif QUEUE_MAX_VALUE <= last_queue evenize_res = ff_evenize ( posted_grove , nil , nil , 1 ) if evenize_res . blank? return false end append_queue = evenize_res [ SPROUT_VACANT_QUEUE_KEY ] elsif QUEUE_MAX_VALUE - last_queue < QUEUE_DEFAULT_INTERVAL append_queue = QUEUE_MAX_VALUE else append_queue = last_queue + QUEUE_DEFAULT_INTERVAL end fill_info . merge ( { ff_queue : append_queue } ) end
Calculate depth and queue as root node to append.
Calculate depth and queue as root node to append .
# can be null=zero # When append as root, need to post ff_grove. # TODO: set error message 'append_empty_column' # depth is fixed value #################################################################### # # calculate queue # # get max queue in grove # can be nil # Try to scoot over pre-nodes. # 1: append node count # When fail to evenize, filled all id. # TODO: set error append.canNotScootsOver' # return value
Calculated queue and depth.
Calculated queue and depth .
Hash
Can not calculate.
Can not calculate .
false
node
<not_specific>