Class: Accessibility::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/accessibility/factory.rb

Overview

AXElements extensions to the Accessibility::Element class

Constant Summary collapse

TRANSLATOR =

Reference to the singleton instance of the translator.

Accessibility::Translator.instance

Instance Method Summary collapse

Instance Method Details

#to_rubyAX::Element

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

Returns:


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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