Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/string.rb,
lib/checker/css.rb

Instance Method Summary collapse

Instance Method Details

#comma_separated_wordsObject



25
26
27
# File 'lib/checker/css.rb', line 25

def comma_separated_words
  split(',').map(&:strip)
end

#css_valuesObject

Avoids properties like rgb(5, 10, 15) to be split



21
22
23
# File 'lib/checker/css.rb', line 21

def css_values
  scan /[^\s]+\(\s*\g<0>\s*(?:,\s*\g<0>)*\)|[^\s]+/
end

#escape_htmlObject



2
3
4
# File 'lib/extensions/string.rb', line 2

def escape_html
  ERB::Util.html_escape self
end

#get_extensionObject



6
7
8
# File 'lib/extensions/string.rb', line 6

def get_extension
  self.split('.').last
end

#get_string_between_markers(starter, ender) ⇒ Object



29
30
31
# File 'lib/checker/css.rb', line 29

def get_string_between_markers(starter, ender)
  self[/#{Regexp.escape(starter)}(.*?)#{Regexp.escape(ender)}/m, 1]
end

#remove_string_between_markers(starter, ender) ⇒ Object



33
34
35
# File 'lib/checker/css.rb', line 33

def remove_string_between_markers(starter, ender)
  gsub(/#{starter}.*#{ender}/, '')
end