Class: PrismChecker::ElementWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/prism_checker/element_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ ElementWrapper

Returns a new instance of ElementWrapper.



7
8
9
# File 'lib/prism_checker/element_wrapper.rb', line 7

def initialize(element)
  @element = element
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/prism_checker/element_wrapper.rb', line 35

def method_missing(method, *args)
  if @element.respond_to?(method)
    return @element.send(method, *args)
  end

  ret = @element[method]

  if ret.nil? && !method.start_with?('data-')
    raise NoMethodError, "unknown attribute '#{method}'"
  end

  ret
end

Instance Method Details

#checkedObject



15
16
17
# File 'lib/prism_checker/element_wrapper.rb', line 15

def checked
  @element.checked?
end

#classObject



11
12
13
# File 'lib/prism_checker/element_wrapper.rb', line 11

def class
  @element[:class]
end

#disabledObject



19
20
21
# File 'lib/prism_checker/element_wrapper.rb', line 19

def disabled
  @element.disabled?
end

#multipleObject



23
24
25
# File 'lib/prism_checker/element_wrapper.rb', line 23

def multiple
  @element.multiple?
end

#readonlyObject



27
28
29
# File 'lib/prism_checker/element_wrapper.rb', line 27

def readonly
  @element.readonly?
end

#respond_to_missing?(*_args) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/prism_checker/element_wrapper.rb', line 49

def respond_to_missing?(*_args)
  true
end

#selectedObject



31
32
33
# File 'lib/prism_checker/element_wrapper.rb', line 31

def selected
  @element.selected?
end