Class: BillyMays::CapitalizeWords

Inherits:
Object
  • Object
show all
Defined in:
lib/sqlize.rb

Direct Known Subclasses

Postgresql, SQL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orig) ⇒ CapitalizeWords

Returns a new instance of CapitalizeWords.



24
25
26
# File 'lib/sqlize.rb', line 24

def initialize(orig)
  @orig = orig
end

Instance Attribute Details

#capitalizedObject

Returns the value of attribute capitalized.



23
24
25
# File 'lib/sqlize.rb', line 23

def capitalized
  @capitalized
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



22
23
24
# File 'lib/sqlize.rb', line 22

def keywords
  @keywords
end

#origObject

Returns the value of attribute orig.



23
24
25
# File 'lib/sqlize.rb', line 23

def orig
  @orig
end

Instance Method Details

#capitalizeObject



28
29
30
31
# File 'lib/sqlize.rb', line 28

def capitalize
  regex = Regexp.new /\b#{Regexp.union @keywords.map{|w|Regexp.new(w, Regexp::IGNORECASE)}}\b/
  @capitalized = @orig.gsub regex, &:upcase
end