123456789_123456789_123456789_123456789_123456789_

Class: Selenium::WebDriver::BiDi::Struct

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Struct
Instance Chain:
self, Struct
Inherits: Struct
  • Object
Defined in: rb/lib/selenium/webdriver/bidi/struct.rb

Class Method Summary

Constructor Details

.new(*args, &block) ⇒ Struct

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/struct.rb', line 25

def new(*args, &block)
  super(*args) do
    define_method(:initialize) do |**kwargs|
      converted_kwargs = kwargs.transform_keys { |key| self.class.camel_to_snake(key.to_s).to_sym }
      super(*converted_kwargs.values_at(*self.class.members))
    end
    class_eval(&block) if block
  end
end

Class Method Details

.camel_to_snake(camel_str)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/struct.rb', line 35

def camel_to_snake(camel_str)
  camel_str.gsub(/([A-Z])/, '_\1').downcase
end