Module: AccessibleFragment

Included in:
RightScale::Base
Defined in:
lib/right_api/accessible_fragment.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



15
16
17
18
# File 'lib/right_api/accessible_fragment.rb', line 15

def method_missing(method_name, *args)
  name_with_dashes = method_name.to_s.gsub('_', '-')
  has_element?(name_with_dashes) ? get_element(name_with_dashes) : super
end

Instance Method Details

#get_element(elem) ⇒ Object



11
12
13
# File 'lib/right_api/accessible_fragment.rb', line 11

def get_element(elem)
  @data.search(elem).first.inner_text
end

#has_element?(elem) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/right_api/accessible_fragment.rb', line 7

def has_element?(elem)
  !@data.search(elem).size.zero?
end

#initialize(data, connection) ⇒ Object



2
3
4
5
# File 'lib/right_api/accessible_fragment.rb', line 2

def initialize(data, connection)
  @data = data
  @connection = connection
end