class FakeFS::File::Stat

def check_if_bit_set(bit)

def check_if_bit_set(bit)
  # get user's group and user ids
  # NOTE: I am picking `Process` over `Etc` as we use `Process`
  # when instaniating file classes. It may be worth it to ensure
  # our Process/Group detection scheme is robust in all cases
  uid = Process.uid
  gid = Process.gid
  # check if bit set for owner
  owner_bits = (@mode >> 6) & 0o7
  if uid == @uid
    # the user is locked out of the file if they are owner of the file
    # but do not have the bit set at the user level
    return true if owner_bits & bit == bit
    return false
  end
  # check if bit set for group
  group_bits = (@mode >> 3) & 0o7
  if gid == @gid
    # the user is locked out of the file if they are in the group that
    # owns the file but do not have the bit set at the group level
    return true if group_bits & bit == bit
    return false
  end
  # check if bit set for world
  world_bits = @mode & 0o7
  return true if world_bits & bit == bit
  false
end