Dismiss ios keyboard after typing in 1.6 and ruby

Im having an issue where the keyboard isnt minimising after calling send_keys to an element and its blocking screen elements and causing tests to fail.

is there a way to close the keyboard with an appium call?
if not what would be a good way to do this without adding a massive amount of calls (eg search for keyboard after every send keys, if visible minimise, check minimised)?

I found this post:
https://discuss.appium.io/t/appium-ios-guide-hiding-the-keyboard-on-real-devices/8221

i like to close iOS keyboard by tap on last key:

public boolean tapLastKeyboardKey_iOS() {
    System.out.println("   tapLastKeyboardKey_iOS()");
    List<WebElement> el;
    try {
        el = driver.findElements(MobileBy.className("XCUIElementTypeKeyboard")).get(0).findElements(MobileBy.className("XCUIElementTypeButton"));
    } catch (Exception e) {
    	System.out.println("   tapLastKeyboardKey_iOS(): looks like keyboard closed!");
        return false;
    }
    try {
    	new TouchAction((MobileDriver) driver).press((MobileElement) el.get(el.size() - 1)).waitAction(50).release().perform();
    	return true;
    } catch (Exception e) {
    	//ignore
    }
    System.out.println("   tapLastKeyboardKey_iOS(): looks like keyboard closed!");
    return false;
}

what would the ruby equiv be for findElements(MobileBy.className(“blah blah”))?

EDIT**
ok so I’ve used this method and its working well.
ok so I’ve used this method and its working well.
def hide_keyboard
begin
log “Hiding the keyboard”
keys = $driver.find_elements(:class_name, “XCUIElementTypeKeyboard”)
.find_elements(:class_name, “XCUIElementTypeButton”)
keys[keys.length - 1].click
rescue StandardError
log “No keyboard visible to hide!”
end
end