Check for a specific element in the script

So I want to make flying enemies that can only be damaged by long range weapons. So far I've made a state called Flying and attached it to enemies that can fly automatically when the battle starts. I've also added a Long Range element to the list of elements. The code I have so far is as follows. 


    if self.state?(24) and attacker.element_set != 14 #Flying enemies
      print attacker.element_set
      hit_result = false
    else
      # First hit detection
      hit_result = (rand(100) < attacker.hit)
    end


Where 14 is the Long Range element and 24 is the Flying state.


The problem is I don't know how to parse the element set to get just the number I need. The If statement always returns true no matter what weapon I'm using to attack flying enemies. Using print I can see that the number being displayed is 14 when I attack using long range weapons yet the statement still won't return false. I thought it might be because attacker.element_set is read as a string so I tried using "14" but that didn't help. I've also tested it with two elements and found that is lists them as a continous number so like 214 if a long range Ice Weapon. I'm sure there's a built in method for breaking up the array but even if I knew it, I'm  not sure what it is and how I could use it to check for this specific element.
Never mind. Managed to figure it out myself. Key is to stick it in a for loop. For the sake of prosterity, here is my code.


if self.state?(24)      #Flying enemies 
      hit_result = (rand(500) < attacker.hit)
      for i in attacker.element_set
        if i == 14
          hit_result = true
        end
      end
    else
      # First hit detection
      hit_result = (rand(100) < attacker.hit)
    end


Where 24 is the flying state and 14 is the long range element.

Original thread: https://forums.rpgmakerweb.com/threads/check-for-a-specific-element-in-the-script.70356/