Class: LinkTag
- Inherits:
-
REXML::Element
- Object
- REXML::Element
- LinkTag
- Defined in:
- lib/ribit/xhtmltag.rb
Constant Summary collapse
- NAME =
'a'- HREF =
'href'
Instance Method Summary collapse
-
#initialize(href, linkText, escape = true) ⇒ LinkTag
constructor
A new instance of LinkTag.
- #set_class(cssClass) ⇒ Object
- #to_s ⇒ Object
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_s ⇒ Object
172 173 174 175 176 |
# File 'lib/ribit/xhtmltag.rb', line 172 def to_s output = '' write( output ) return output end |