Class: String

Inherits:
Object show all
Defined in:
lib/tm2gsv/extensions.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


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

def blank?
  self.strip == ""
end

#color?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/tm2gsv/extensions.rb', line 23

def color?
  if self.include? '#' and self.size > 6
    return true
  end

  return false
end

#color_with_alpha?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/tm2gsv/extensions.rb', line 31

def color_with_alpha?
  if self.include? '#' and self.size > 7
    return true
  end

  return false
end

#dasherizeObject



47
48
49
# File 'lib/tm2gsv/extensions.rb', line 47

def dasherize
  self.downcase.gsub(/[^0-9A-Za-z]/, ' ').squeeze(' ').gsub(' ', '-').strip
end

#to_hex_alphaObject



43
44
45
# File 'lib/tm2gsv/extensions.rb', line 43

def to_hex_alpha
  (100 * ((self[7,8]).to_i(16) / 255.0)).round
end

#to_hex_colorObject



39
40
41
# File 'lib/tm2gsv/extensions.rb', line 39

def to_hex_color
  self[0..6]
end