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.



20
21
22
# File 'lib/sqlize.rb', line 20

def initialize(orig)
  @orig = orig
end

Instance Attribute Details

#capitalizedObject

Returns the value of attribute capitalized.



19
20
21
# File 'lib/sqlize.rb', line 19

def capitalized
  @capitalized
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



18
19
20
# File 'lib/sqlize.rb', line 18

def keywords
  @keywords
end

#origObject

Returns the value of attribute orig.



19
20
21
# File 'lib/sqlize.rb', line 19

def orig
  @orig
end

Instance Method Details

#capitalizeObject



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

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