Class: CongressForms::Actions::Base
- Inherits:
-
Object
- Object
- CongressForms::Actions::Base
- Defined in:
- lib/congress_forms/actions.rb
Direct Known Subclasses
Check, Choose, ClickOn, FillIn, Find, Javascript, Select, Uncheck, Visit, Wait
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#required ⇒ Object
(also: #required?)
Returns the value of attribute required.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #escape_css_attribute(v) ⇒ Object
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #max_length ⇒ Object
- #placeholder_value? ⇒ Boolean
- #select_options ⇒ Object
- #submit? ⇒ Boolean
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. = 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 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 .is_a?(Hash) ? ["max_length"] : nil end |
#placeholder_value? ⇒ 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 [Choose, Select].include?(self.class) ? : nil end |
#submit? ⇒ Boolean
47 48 49 |
# File 'lib/congress_forms/actions.rb', line 47 def submit? "#{value} #{selector}".match(/submit/i) end |