Class: SideToCapybara::Base
- Inherits:
-
Object
- Object
- SideToCapybara::Base
- Defined in:
- lib/side_to_capybara/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#side_command ⇒ Object
readonly
Returns the value of attribute side_command.
Instance Method Summary collapse
- #command ⇒ Object
- #comment ⇒ Object
- #id ⇒ Object
-
#initialize(side_command) ⇒ Base
constructor
A new instance of Base.
- #selector ⇒ Object
- #selector_type ⇒ Object
- #target ⇒ Object
- #targets ⇒ Object
-
#translate ⇒ Object
returns the translation of the command or a warning if the command can’t be translated.
- #value ⇒ Object
Constructor Details
#initialize(side_command) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/side_to_capybara/base.rb', line 5 def initialize(side_command) @side_command = side_command end |
Instance Attribute Details
#side_command ⇒ Object (readonly)
Returns the value of attribute side_command.
4 5 6 |
# File 'lib/side_to_capybara/base.rb', line 4 def side_command @side_command end |
Instance Method Details
#command ⇒ Object
21 22 23 |
# File 'lib/side_to_capybara/base.rb', line 21 def command @side_command['command'] end |
#comment ⇒ Object
25 26 27 |
# File 'lib/side_to_capybara/base.rb', line 25 def comment @side_command['comment'] end |
#id ⇒ Object
29 30 31 |
# File 'lib/side_to_capybara/base.rb', line 29 def id @side_command['id'] end |
#selector ⇒ Object
37 38 39 |
# File 'lib/side_to_capybara/base.rb', line 37 def selector _selector(target) end |
#selector_type ⇒ Object
33 34 35 |
# File 'lib/side_to_capybara/base.rb', line 33 def selector_type _selector_type(target) end |
#target ⇒ Object
9 10 11 |
# File 'lib/side_to_capybara/base.rb', line 9 def target @side_command['target'] end |
#targets ⇒ Object
13 14 15 |
# File 'lib/side_to_capybara/base.rb', line 13 def targets @side_command['targets'] end |
#translate ⇒ Object
returns the translation of the command or a warning if the command can’t be translated
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/side_to_capybara/base.rb', line 42 def translate method_id = command.gsub(/([a-z])([A-Z])/, '\1_\2').downcase if self.class.public_method_defined?(method_id) # the translation itself translation = public_send(method_id) return "# WARNING: '#{command}' found but the selector_type '#{selector_type}' is unhandled." if translation.nil? # add the alternative selectors as comments if present if targets.size > 1 "#{commented_targets.join("\n")}\n#{translation}" else translation end else "# WARNING: Conversion for '#{command}' not found." end end |
#value ⇒ Object
17 18 19 |
# File 'lib/side_to_capybara/base.rb', line 17 def value @side_command['value'] end |