Class: String

Inherits:
Object show all
Defined in:
lib/sapphire/Extensions/String.rb

Instance Method Summary collapse

Instance Method Details

#+(item) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/sapphire/Extensions/String.rb', line 13

def +(item)

  return plus("") if item.nil?
  return plus(item) if item.is_a? String
  return plus(Parameter(item)) if Sapphire::DSL::TestPlans::Parameters.instance.Contains(item)

  raise "No Parameter defined for: " << item.to_s if item.is_a? Symbol and !item.nil?

  plus(item)
end

#For(item) ⇒ Object



24
25
26
# File 'lib/sapphire/Extensions/String.rb', line 24

def For(item)
  item
end

#namespaceObject



28
29
30
31
32
33
# File 'lib/sapphire/Extensions/String.rb', line 28

def namespace
  self.gsub(/::/, '_').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_")
end

#plusObject



3
# File 'lib/sapphire/Extensions/String.rb', line 3

alias_method :"plus", :"+"

#underscoreObject



5
6
7
8
9
10
11
# File 'lib/sapphire/Extensions/String.rb', line 5

def underscore
  self.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
end