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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



24
25
26
27
28
29
# File 'lib/congress_forms/actions.rb', line 24

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

Instance Attribute Details

#options ⇒ Object

Returns the value of attribute options.



21
22
23
# File 'lib/congress_forms/actions.rb', line 21

def options
  @options
end

#required ⇒ Object Also known as: required?

Returns the value of attribute required.



21
22
23
# File 'lib/congress_forms/actions.rb', line 21

def required
  @required
end

#selector ⇒ Object

Returns the value of attribute selector.



21
22
23
# File 'lib/congress_forms/actions.rb', line 21

def selector
  @selector
end

#value ⇒ Object

Returns the value of attribute value.



21
22
23
# File 'lib/congress_forms/actions.rb', line 21

def value
  @value
end

Instance Method Details

#escape_css_attribute(v) ⇒ Object



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

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

#inspect ⇒ Object



51
52
53
54
55
# File 'lib/congress_forms/actions.rb', line 51

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

#max_length ⇒ Object



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

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

#placeholder_value? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#select_options ⇒ Object



35
36
37
# File 'lib/congress_forms/actions.rb', line 35

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

#submit? ⇒ Boolean

Returns:

  • (Boolean)


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

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