Class: IcimsClient::IcimsAttributeValue

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

Overview

An attribute value as returned by IcimsJob methods

Instance Method Summary collapse

Instance Method Details

#custom_html_entity_translation!Object

Executes a custom HTML entity translation based upon organizational bias/preference



150
151
152
153
154
155
156
157
158
# File 'lib/icims_client.rb', line 150

def custom_html_entity_translation!

  #We have an ASCII bias on certain HTML entity translations, even though
  #they're technically inaccurate.  This is because we're commonly displaying in web pages
  #and browsers (still) inconsistently implement these characters
  self.gsub!(/ /, ' ')
  self.gsub!(/’/, '\'')
  self.gsub!(/‘/, '\'')
end

#minify_whitespace!Object

Strips leading and trailing whitespace. Turns multiple internal whitespace characters to a single space.



164
165
166
167
168
169
170
# File 'lib/icims_client.rb', line 164

def minify_whitespace!
  #strip leading/tailing whitespace.
  self.strip!

  #eliminate multiple whitespace characters
  self.gsub!(/\s{2,}/, ' ')
end

#sanitizeObject

Returns a sanitized IcimsAttributeValue. Idempotent.



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/icims_client.rb', line 175

def sanitize

  self.custom_html_entity_translation!

  #strip out all of the HTML tags, but entities are preserved
  sanitized_string = Sanitize.clean(self)

  # convert HTML entities to text
  # We can't use this to strip HTML tags because critical whitespace is eliminated 
  # causing nastiness like wordsandparagraphsflowingtogether
  sanitized_attr = IcimsAttributeValue.new(Nokogiri::HTML(sanitized_string).text)
  sanitized_attr.minify_whitespace!
  return sanitized_attr
  
end