Sha256: b1a7caddf26af600de8b1776b80865395ea18290adc3cd42c2cd83aca881c727

Contents?: true

Size: 688 Bytes

Versions: 30

Compression:

Stored size: 688 Bytes

Contents

module Watir
  class Util
    class << self
      #
      # "Watir::Span" => "Span"
      # 
      def demodulize(str)
        str.gsub(/^.*::/, '')
      end

      #
      # "FooBar" => "foo_bar"
      # 
      def underscore(str)
        str.gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
      end

      #
      # "Checkboxes" => "Checkbox"
      # "Bodies" => "Body"
      # "Buttons" => "Button"
      #
      def singularize(str)
        case str.downcase
        when "checkboxes"
          str.chop.chop
        when "bodies"
          str.chop.chop.chop + "y"
        else
          str.chop
        end
      end
    end    
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
watir-classic-3.3.0 lib/watir-classic/util.rb
watir-classic-3.2.0 lib/watir-classic/util.rb
watir-classic-3.2.0.rc1 lib/watir-classic/util.rb
watir-classic-3.1.0 lib/watir-classic/util.rb
watir-classic-3.0.0 lib/watir-classic/util.rb
commonwatir-3.0.0.rc3 lib/watir/util.rb
commonwatir-3.0.0.rc2 lib/watir/util.rb
commonwatir-3.0.0.rc1 lib/watir/util.rb
commonwatir-2.0.4 lib/watir/util.rb
commonwatir-2.0.3 lib/watir/util.rb
commonwatir-2.0.2 lib/watir/util.rb
commonwatir-2.0.2.rc1 lib/watir/util.rb
commonwatir-2.0.1 lib/watir/util.rb
commonwatir-2.0.0 lib/watir/util.rb
commonwatir-2.0.0.rc3 lib/watir/util.rb
commonwatir-2.0.0.rc2 lib/watir/util.rb
commonwatir-1.9.2 lib/watir/util.rb
commonwatir-1.9.2.rc1 lib/watir/util.rb
commonwatir-1.9.1 lib/watir/util.rb
commonwatir-1.9.1.rc1 lib/watir/util.rb