class Accessibility::Element

‘AXElements` extensions to the `Accessibility::Element` class

Constants

TRANSLATOR

@private

Reference to the singleton instance of the translator.

@return [Accessibility::Translator]

Public Instance Methods

to_ruby() click to toggle source

Override the default ‘#to_ruby` so that proper classes are chosen for each object.

@return [AX::Element]

# File lib/accessibility/factory.rb, line 112
def to_ruby
  if roll = self.role
    roll = TRANSLATOR.unprefix roll
    if attributes.include? KAXSubroleAttribute
      subroll = self.subrole
      # Some objects claim to have a subrole but return nil
      if subroll
        AX.class_for2(TRANSLATOR.unprefix(subroll), roll).new self
      else
        AX.class_for(roll).new self
      end
    else
      AX.class_for(roll).new self
    end
  else # failsafe in case object dies before we get the role
    AX::Element.new self
  end
end