lib/fertile_forest/modules/finders.rb
#
# Find nth-child node from base node.
#
# @param base_obj [Entity|Integer] Base node|id to find.
# @param nth [Integer] Order in child nodes.
# @param columns [Array] Columns for SELECT clause.
# @return [Entity] Nth-child node.
# @return [nil] No nth-child node.
#
Find nth-child node from base node.
Find nth - child node from base node .
def nth_child(base_obj, nth = 0, columns = nil)
            children_query = children(base_obj, columns)
            nth = nth.to_i
            if nth < 0
              sibling_count = children_query.all.length
              nth = sibling_count - 1
              return nil if nth < 0
            end
            children_query.offset(nth).first
          end
def nth_child ( base_obj , nth = 0 , columns = nil ) children_query = children ( base_obj , columns ) nth = nth . to_i if nth < 0 sibling_count = children_query . all . length nth = sibling_count - 1 return nil if nth < 0 end children_query . offset ( nth ) . first end
Find nth-child node from base node.
Find nth - child node from base node .
None
Entity
No nth-child node.
No nth - child node .
nil
base_obj
Base node|id to find.
Base node|id to find .
nth
Order in child nodes.
Order in child nodes .
columns
Columns for SELECT clause.
Columns for SELECT clause .