Class: Deface::Actions::AttributeAction

Inherits:
Action
  • Object
show all
Defined in:
lib/deface/actions/attribute_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Action

#range_compatible?, to_sym

Constructor Details

#initialize(options = {}) ⇒ AttributeAction

Returns a new instance of AttributeAction.

Raises:



6
7
8
9
10
# File 'lib/deface/actions/attribute_action.rb', line 6

def initialize(options = {})
  super options
  @attributes = options[:attributes]
  raise(DefaceError, "No attributes option specified") unless @attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/deface/actions/attribute_action.rb', line 4

def attributes
  @attributes
end

Instance Method Details

#execute(target_element) ⇒ Object



12
13
14
15
16
17
# File 'lib/deface/actions/attribute_action.rb', line 12

def execute(target_element)
  target_element = target_element.first
  attributes.each do |name, value|
    execute_for_attribute(target_element, normalize_attribute_name(name), value)
  end
end