Class: CongressForms::Actions::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/congress_forms/actions.rb

Direct Known Subclasses

Check, Choose, ClickOn, FillIn, Find, Javascript, Select, Uncheck, Visit, Wait, Yield

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



31
32
33
34
35
36
# File 'lib/congress_forms/actions.rb', line 31

def initialize(params = {})
  self.selector = params["selector"]
  self.value = params["value"]
  self.options = params["options"] || {}
  self.required = !!params["required"]
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



28
29
30
# File 'lib/congress_forms/actions.rb', line 28

def options
  @options
end

#requiredObject Also known as: required?

Returns the value of attribute required.



28
29
30
# File 'lib/congress_forms/actions.rb', line 28

def required
  @required
end

#selectorObject

Returns the value of attribute selector.



28
29
30
# File 'lib/congress_forms/actions.rb', line 28

def selector
  @selector
end

#valueObject

Returns the value of attribute value.



28
29
30
# File 'lib/congress_forms/actions.rb', line 28

def value
  @value
end

Instance Method Details

#escape_css_attribute(v) ⇒ Object



50
51
52
# File 'lib/congress_forms/actions.rb', line 50

def escape_css_attribute(v)
  v.gsub('"', '\"')
end

#inspectObject



58
59
60
61
62
# File 'lib/congress_forms/actions.rb', line 58

def inspect
  s = "#{self.class.name.sub(/^CongressForms::Actions::/, '')}("
  s << "#{selector.inspect}, " unless selector.nil?
  s << value.inspect << ")"
end

#max_lengthObject



38
39
40
# File 'lib/congress_forms/actions.rb', line 38

def max_length
  options.is_a?(Hash) ? options["max_length"] : nil
end

#placeholder_value?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/congress_forms/actions.rb', line 46

def placeholder_value?
  value[0, 1] == "$"
end

#select_optionsObject



42
43
44
# File 'lib/congress_forms/actions.rb', line 42

def select_options
  [Choose, Select].include?(self.class) ? options : nil
end

#submit?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/congress_forms/actions.rb', line 54

def submit?
  "#{value} #{selector}".match(/submit/i)
end