module Familyable::Familynize
this module require id, parent_ids fileds.
Public Instance Methods
get_brothers(person)
click to toggle source
# File lib/familyable/familynize.rb, line 28 def get_brothers(person) ret = [] tmp_family = family.dup person.parent_ids.each do |parent_id| tmp_family.each do |v| next if v == person next unless v.parent_ids.include?(parent_id) ret << v tmp_family.delete(v) end end ret end
get_children(person)
click to toggle source
# File lib/familyable/familynize.rb, line 21 def get_children(person) family.reduce([]) do |ret, v| ret << v if v.parent_ids.include?(person.id) ret end end
get_parents(person)
click to toggle source
# File lib/familyable/familynize.rb, line 8 def get_parents(person) ret = [] tmp_family = family.dup person.parent_ids.each do |parent_id| tmp_family.each do |v| next unless v.id == parent_id ret << v tmp_family.delete(v) end end ret end