Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/win32rc/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#begin?(other_str) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/win32rc/core_ext/string.rb', line 3

def begin?(other_str)
  self.index(other_str) == 0
end

#end?(other_str) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/win32rc/core_ext/string.rb', line 7

def end?(other_str)
  i = self.rindex(other_str)
  return false if i.nil?
  return (self.length == i + other_str.length)
end

#win32_versionize(sep = ',') ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/win32rc/core_ext/string.rb', line 13

def win32_versionize(sep = ',')
  components = self.split('.', 4)
  while components.size < 4
    components.push('0')
  end
  
  return components.join(sep)
end