Checking if enemy is dead through Ruby

Hey, I've been using VX Ace for years now, but only recently have I been forced to script with Ruby, and I'm at a standstill.

There is a boss fight in the game I'm making where it's supposed to check if a certain enemy is dead (enemy, not actor), and if it is, then increase the value of a variable by 1 and turn a certain switch on. It does that with every enemy, increases the number of the same variable, but the switch activated is different for each enemy. Yeah, I know I could just use the Conditional Branch for that, but let's say that, because of certain restrictions, I'm being forced to do this through Ruby.

Now the problem is that I don't know how to make it so that the game can detect whether a certain enemy is dead or not. I did an attempt that runs at the end of every turn, and it looks like this:

def enemy ; $game_troop.members[1]
if enemy == (enemy.state?(1))
$game_variables[989] += 1
$game_switches[969] = true
end
end

However, even if the enemy dies, nothing happens. I have a test text scripted to appear if the switch has been turned on. It doesn't appear, meaning the switch hasn't turned on, further meaning that the code doesn't work. If anyone could guide me on how I'm supposed to write the code, I'd really appreciate it.
Tell me, where did you place that scriptlet of yours?

Why don't you ask for something kind of obvious like hp0? or dead? or hp == 0 , @MeeMFromHH ?
I made it so that it runs at the end of every turn. I'm a bit new to scripting, and I was kinda stressed earlier today because of a few things so it didn't come to me to ask the program to look for something more specific. I'll try that out later.
Well, I couldn't figure it out, but I found another way. It's not a perfect solution, but it's better than nothing.

Original thread: https://forums.rpgmakerweb.com/threads/checking-if-enemy-is-dead-through-ruby.148203/