lib/watir/generator/base/visitor.rb in watir-7.1.0 vs lib/watir/generator/base/visitor.rb in watir-7.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Watir
module Generator
class Base
class Visitor < WebIDL::RubySexpVisitor
STRING_TYPES = ['WindowProxy', 'ValidityState', 'TimeRanges', 'Location',
@@ -7,11 +9,11 @@
/Media.+/, 'TextTrackKind', 'Function', /.*EventHandler$/,
'Document', 'DocumentFragment', 'DOMTokenList', 'DOMSettableTokenList',
'DOMStringMap', 'HTMLPropertiesCollection', /HTML.*Element/, /HTML.*Collection/,
'CSSStyleDeclaration', /.+List$/, 'Date', 'Element', /DOM.+ReadOnly/,
/SVGAnimated.+/, /SVG.*Element/, /SVG.*Collection/, 'SVGViewSpec',
- 'Object', 'USVString'].freeze
+ 'Object', 'USVString', 'DOMString', 'any'].freeze
def initialize
super
# When an interface has multiple IDL definitions in the spec, the inheritance is sometimes
# not repeated. So we'll keep track ourselves.
@@ -109,21 +111,19 @@
str.to_sym
end
def ruby_type_for(type)
case type.name.to_s
- when 'DOMString', 'any'
+ when *STRING_TYPES
+ # probably completely wrong.
String
when 'UnsignedLong', 'Long', 'Integer', 'Short', 'UnsignedShort',
'SVGAnimatedLength'
Integer
when 'Float', /.*Double$/
Float
when 'Boolean'
'Boolean'
- when *STRING_TYPES
- # probably completely wrong.
- String
else
raise "unknown type: #{type.name}"
end
end
end # Visitor