Class: LinkTag

Inherits:
REXML::Element
  • Object
show all
Defined in:
lib/ribit/xhtmltag.rb

Constant Summary collapse

NAME =
'a'
HREF =
'href'

Instance Method Summary collapse

Constructor Details

#initialize(href, linkText, escape = true) ⇒ LinkTag

Returns a new instance of LinkTag.



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/ribit/xhtmltag.rb', line 146

def initialize( href, linkText, escape=true )
	super( NAME, nil, { :raw=>:all } )
	if ( escape )
		href = URI.escape( href.to_s )
		attributes[HREF] = href
		
    else
      if ( href != nil )
   	    # entities has to be encoded
   	    href = href.to_s
   	    href.gsub!( /&/, '&' )
      end
      attr = RawAttribute.new( HREF, href.to_s )
	  add_attribute( attr )
	  #print( "href="+ attr.to_s + "\n")
	end
	
	self.text = linkText
end

Instance Method Details

#set_class(cssClass) ⇒ Object



167
168
169
# File 'lib/ribit/xhtmltag.rb', line 167

def set_class( cssClass )
  add_attribute( "class", cssClass )
end

#to_sObject



172
173
174
175
176
# File 'lib/ribit/xhtmltag.rb', line 172

def to_s
	output = ''
	write( output )
	return output
end