class SimpleSauce::Options
Constants
- SAUCE
- W3C
Public Class Methods
camel_case(str)
click to toggle source
# File lib/simple_sauce/options.rb, line 6 def camel_case(str) str.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase } end
new(**opts)
click to toggle source
# File lib/simple_sauce/options.rb, line 20 def initialize(**opts) @browser_name = 'chrome' @platform_name = 'Windows 10' @browser_version = 'latest' create_variables(SAUCE + W3C, opts) end
Public Instance Methods
capabilities()
click to toggle source
# File lib/simple_sauce/options.rb, line 28 def capabilities caps = W3C.each_with_object({}) do |key, hash| value = send(key) hash[self.class.camel_case(key)] = value if value end caps['sauce:options'] = {} SAUCE.each do |key| value = send(key) caps['sauce:options'][self.class.camel_case(key)] = value unless value.nil? end caps end
Also aliased as: as_json
Private Instance Methods
create_variables(key, opts)
click to toggle source
# File lib/simple_sauce/options.rb, line 45 def create_variables(key, opts) key.each do |option| self.class.__send__(:attr_accessor, option) next unless opts.key?(option) instance_variable_set("@#{option}", opts.delete(option)) end return if opts.empty? raise ArgumentError, "#{opts.inspect} are not valid parameters for Options class" end