Sha256: a92183510f9960609a8eeb8f436802e07182565d3ed95d8572ce11d39e8424c3

Contents?: true

Size: 513 Bytes

Versions: 5

Compression:

Stored size: 513 Bytes

Contents

class String
  def snake_case
    gsub(/([a-z])([A-Z0-9])/, '\1_\2' ).downcase
  end
  
  def to_w
    (self+"\x00").encode('utf-16LE')
  end
  
  def to_vkeys
    unless size == 1
      raise "Can't convert but a single character: #{self}"
    end
    ascii = upcase.unpack('C')[0]
    case self
      when 'a'..'z', '0'..'9', ' '
      [ascii]
      when 'A'..'Z'
      [WinGui.const_get(:VK_SHIFT), ascii]
    else
      raise "Can't convert unknown character: #{self}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
win_gui-0.1.4 lib/win_gui/string_extensions.rb
win_gui-0.1.3 lib/win_gui/string_extensions.rb
win_gui-0.1.2 lib/win_gui/string_extensions.rb
win_gui-0.1.1 lib/win_gui/string_extensions.rb
win_gui-0.1.0 lib/win_gui/string_extensions.rb