Class: CssTidy::Comment

Inherits:
CssBase show all
Defined in:
lib/modules/css_comment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CssBase

#inspect, #optimize

Constructor Details

#initialize(text = '') ⇒ Comment

Returns a new instance of Comment.



6
7
8
9
10
# File 'lib/modules/css_comment.rb', line 6

def initialize(text='')
	@text = text
	@printable = true
	self
end

Instance Attribute Details

#printableObject

Returns the value of attribute printable.



4
5
6
# File 'lib/modules/css_comment.rb', line 4

def printable
  @printable
end

#textObject

Returns the value of attribute text.



4
5
6
# File 'lib/modules/css_comment.rb', line 4

def text
  @text
end

Instance Method Details

#<<(text) ⇒ Object



12
13
14
# File 'lib/modules/css_comment.rb', line 12

def << (text)
	@text << text
end

#clearObject



36
37
38
39
# File 'lib/modules/css_comment.rb', line 36

def clear
	@text = ''
	@printable = false
end

#is_ie5_hack?Boolean

looks for a \ at the end of the comment, indicating that it is a the start of an IE5 hack why anyone is still doing this, is beyond me! :-)

Returns:

  • (Boolean)


32
33
34
# File 'lib/modules/css_comment.rb', line 32

def is_ie5_hack?
	text[-1,1] == '\\'
end

#is_special?Boolean

special comments start with a ! and should not be deleted

Returns:

  • (Boolean)


25
26
27
# File 'lib/modules/css_comment.rb', line 25

def is_special?
	text[0,1] == '!'
end

#to_s(format = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/modules/css_comment.rb', line 16

def to_s(format=nil)
	if @printable
		"/*#{@text}*/"
	else
		''
	end
end