Module: HTML::Mixin::AttributeHandler
- Included in:
- Table, Table::Caption, Table::ColGroup, Table::TableSection, Table::ColGroup::Col, Table::Row, Table::Row::Data, Table::Row::Header
- Defined in:
- lib/html/mixin/attribute_handler.rb
Instance Method Summary collapse
- #abbr(string = nil) ⇒ Object
- #abbr=(string) ⇒ Object
- #align(position = nil) ⇒ Object
- #align=(position) ⇒ Object
- #axis(string = nil) ⇒ Object
- #axis=(string) ⇒ Object
- #background(url = nil) ⇒ Object
- #background=(url) ⇒ Object
- #bgcolor(color = nil) ⇒ Object
- #bgcolor=(color) ⇒ Object
- #border(num = nil) ⇒ Object
-
#border=(num) ⇒ Object
Allow either true/false or an integer.
- #bordercolor(color = nil) ⇒ Object
- #bordercolor=(color) ⇒ Object
- #bordercolordark(color = nil) ⇒ Object
- #bordercolordark=(color) ⇒ Object
- #bordercolorlight(color = nil) ⇒ Object
- #bordercolorlight=(color) ⇒ Object
- #cellpadding(num = nil) ⇒ Object
- #cellpadding=(num) ⇒ Object
- #cellspacing(num = nil) ⇒ Object
- #cellspacing=(num) ⇒ Object
- #char(character = nil) ⇒ Object
- #char=(character) ⇒ Object
- #charoff(offset = nil) ⇒ Object
- #charoff=(offset) ⇒ Object
-
#class_(klass = nil) ⇒ Object
Returns the CSS class.
-
#class_=(klass) ⇒ Object
Returns the CSS class.
- #col(num = nil) ⇒ Object
- #col=(num) ⇒ Object
- #colspan(span = nil) ⇒ Object
- #colspan=(span) ⇒ Object
-
#configure(row, col = nil, &block) ⇒ Object
Allows you to configure various attributes by row or row + column.
-
#content(arg = nil, &block) ⇒ Object
(also: #data)
Returns the HTML content (i.e. text).
- #frame(type = nil) ⇒ Object
- #frame=(type) ⇒ Object
- #height(num = nil) ⇒ Object
- #height=(num) ⇒ Object
- #hspace(num = nil) ⇒ Object
- #hspace=(num) ⇒ Object
- #nowrap(bool = nil) ⇒ Object
- #nowrap=(bool) ⇒ Object
- #rowspan(num = nil) ⇒ Object
- #rowspan=(num) ⇒ Object
- #rules(edges = nil) ⇒ Object
- #rules=(edges) ⇒ Object
- #span(num = nil) ⇒ Object
- #span=(num) ⇒ Object
- #style(string = nil) ⇒ Object
- #style=(string) ⇒ Object
- #summary(string = nil) ⇒ Object
- #summary=(string) ⇒ Object
- #valign(position = nil) ⇒ Object
- #valign=(position) ⇒ Object
- #vspace(num = nil) ⇒ Object
- #vspace=(num) ⇒ Object
- #width(num = nil) ⇒ Object
- #width=(num) ⇒ Object
Instance Method Details
#abbr(string = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/html/mixin/attribute_handler.rb', line 10 def abbr(string = nil) @abbr ||= nil self.abbr = string if string @abbr end |
#abbr=(string) ⇒ Object
16 17 18 19 |
# File 'lib/html/mixin/attribute_handler.rb', line 16 def abbr=(string) @abbr = string modify_html("abbr", string) end |
#align(position = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/html/mixin/attribute_handler.rb', line 21 def align(position = nil) @align ||= nil self.align = position if position @align end |
#align=(position) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/html/mixin/attribute_handler.rb', line 27 def align=(position) valid = %w/top bottom left center right/ raise ArgumentError unless valid.include?(position.downcase) @align = position modify_html("align", position) end |
#axis(string = nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/html/mixin/attribute_handler.rb', line 34 def axis(string = nil) @axis ||= nil self.axis = string if string @axis end |
#axis=(string) ⇒ Object
40 41 42 43 |
# File 'lib/html/mixin/attribute_handler.rb', line 40 def axis=(string) @axis = string modify_html("axis", string) end |
#background(url = nil) ⇒ Object
45 46 47 48 49 |
# File 'lib/html/mixin/attribute_handler.rb', line 45 def background(url = nil) @background ||= nil self.background = url if url @background end |
#background=(url) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/html/mixin/attribute_handler.rb', line 51 def background=(url) raise TypeError unless url.kind_of?(String) msg = "'background' is a non-standard extension" warn NonStandardExtensionWarning, msg @background = url modify_html("background", url) end |
#bgcolor(color = nil) ⇒ Object
59 60 61 62 63 |
# File 'lib/html/mixin/attribute_handler.rb', line 59 def bgcolor(color = nil) @bgcolor ||= nil self.bgcolor = color if color @bgcolor end |
#bgcolor=(color) ⇒ Object
65 66 67 68 |
# File 'lib/html/mixin/attribute_handler.rb', line 65 def bgcolor=(color) @bgcolor = color modify_html("bgcolor", color) end |
#border(num = nil) ⇒ Object
70 71 72 73 74 |
# File 'lib/html/mixin/attribute_handler.rb', line 70 def border(num = nil) @border ||= nil self.border = num if num @border end |
#border=(num) ⇒ Object
Allow either true/false or an integer
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/html/mixin/attribute_handler.rb', line 77 def border=(num) if num.kind_of?(TrueClass) modify_html("border", true) elsif num.kind_of?(FalseClass) # Do nothing else @border = num.to_i modify_html("border", num.to_i) end end |
#bordercolor(color = nil) ⇒ Object
88 89 90 91 92 |
# File 'lib/html/mixin/attribute_handler.rb', line 88 def bordercolor(color = nil) @bordercolor ||= nil self.bordercolor = color if color @bordercolor end |
#bordercolor=(color) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/html/mixin/attribute_handler.rb', line 94 def bordercolor=(color) @bordercolor = color msg = "'bordercolor' is a non-standard extension" warn NonStandardExtensionWarning, msg modify_html("bordercolor", color) end |
#bordercolordark(color = nil) ⇒ Object
101 102 103 104 105 |
# File 'lib/html/mixin/attribute_handler.rb', line 101 def bordercolordark(color = nil) @bordercolordark ||= nil self.bordercolordark = color if color @bordercolordark end |
#bordercolordark=(color) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/html/mixin/attribute_handler.rb', line 107 def bordercolordark=(color) @bordercolordark = color msg = "'bordercolordark' is a non-standard extension" warn NonStandardExtensionWarning, msg modify_html("bordercolordark", color) end |
#bordercolorlight(color = nil) ⇒ Object
114 115 116 117 118 |
# File 'lib/html/mixin/attribute_handler.rb', line 114 def bordercolorlight(color = nil) @bordercolorlight ||= nil self.bordercolorlight = color if color @bordercolorlight end |
#bordercolorlight=(color) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/html/mixin/attribute_handler.rb', line 120 def bordercolorlight=(color) @bordercolorlight = color msg = "'bordercolorlight' is a non-standard extension" warn NonStandardExtensionWarning, msg modify_html("bordercolorlight", @bordercolorlight) end |
#cellpadding(num = nil) ⇒ Object
127 128 129 130 131 |
# File 'lib/html/mixin/attribute_handler.rb', line 127 def cellpadding(num = nil) @cellpadding ||= nil self.cellpadding = num if num @cellpadding end |
#cellpadding=(num) ⇒ Object
133 134 135 136 137 |
# File 'lib/html/mixin/attribute_handler.rb', line 133 def cellpadding=(num) raise ArgumentError if num.to_i < 0 @cellpadding = num.to_i modify_html("cellpadding", @cellpadding) end |
#cellspacing(num = nil) ⇒ Object
139 140 141 142 143 |
# File 'lib/html/mixin/attribute_handler.rb', line 139 def cellspacing(num = nil) @cellspacing ||= nil self.cellspacing = num if num @cellspacing end |
#cellspacing=(num) ⇒ Object
145 146 147 148 149 |
# File 'lib/html/mixin/attribute_handler.rb', line 145 def cellspacing=(num) raise ArgumentError if num.to_i < 0 @cellspacing = num.to_i modify_html("cellspacing", @cellspacing) end |
#char(character = nil) ⇒ Object
151 152 153 154 155 |
# File 'lib/html/mixin/attribute_handler.rb', line 151 def char(character = nil) @char ||= nil self.char = character if character @char end |
#char=(character) ⇒ Object
157 158 159 160 161 |
# File 'lib/html/mixin/attribute_handler.rb', line 157 def char=(character) raise ArgumentError if character.to_s.length > 1 @char = character.to_s modify_html("char", character.to_s) end |
#charoff(offset = nil) ⇒ Object
163 164 165 166 167 |
# File 'lib/html/mixin/attribute_handler.rb', line 163 def charoff(offset = nil) @charoff ||= nil self.charoff = offset if offset @charoff end |
#charoff=(offset) ⇒ Object
169 170 171 172 173 |
# File 'lib/html/mixin/attribute_handler.rb', line 169 def charoff=(offset) raise ArgumentError if offset.to_i < 0 @charoff = offset modify_html("charoff", offset) end |
#class_(klass = nil) ⇒ Object
Returns the CSS class. The trailing underscore is necessary in order to avoid conflict with the ‘class’ keyword.
178 179 180 181 182 |
# File 'lib/html/mixin/attribute_handler.rb', line 178 def class_(klass = nil) @class ||= nil self.class_ = klass if klass @class end |
#class_=(klass) ⇒ Object
Returns the CSS class. The trailing underscore is necessary in order to avoid conflict with the ‘class’ keyword.
187 188 189 190 |
# File 'lib/html/mixin/attribute_handler.rb', line 187 def class_=(klass) modify_html('class', klass) @class = klass end |
#col(num = nil) ⇒ Object
192 193 194 195 196 |
# File 'lib/html/mixin/attribute_handler.rb', line 192 def col(num = nil) @col ||= nil self.col = num if num @col end |
#col=(num) ⇒ Object
198 199 200 201 202 |
# File 'lib/html/mixin/attribute_handler.rb', line 198 def col=(num) raise ArgumentError if num.to_i < 0 @col = num.to_i modify_html("col", @col) end |
#colspan(span = nil) ⇒ Object
204 205 206 207 208 |
# File 'lib/html/mixin/attribute_handler.rb', line 204 def colspan(span = nil) @colspan ||= nil self.colspan = span if span @colspan end |
#colspan=(span) ⇒ Object
210 211 212 213 214 |
# File 'lib/html/mixin/attribute_handler.rb', line 210 def colspan=(span) raise ArgumentError if span.to_i < 0 @colspan = span.to_i modify_html("colspan", @colspan) end |
#configure(row, col = nil, &block) ⇒ Object
Allows you to configure various attributes by row or row + column.
218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/html/mixin/attribute_handler.rb', line 218 def configure(row, col=nil, &block) if col begin yield self[row][col] rescue NameError msg = "No column to configure in a " + self.class.to_s + " class" raise ArgumentError, msg end else yield self[row] end end |
#content(arg = nil, &block) ⇒ Object Also known as: data
Returns the HTML content (i.e. text).
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/html/mixin/attribute_handler.rb', line 233 def content(arg = nil, &block) case arg when String self.content = Table::Content.new(arg, &block) when Array arg.each{ |e| if e.kind_of?(Array) row = Table::Row.new e.each{ |element| row.push(Table::Content.new(element, &block)) } self.push(row) else self.content = Table::Content.new(e, &block) end } else self.content = arg if arg end @html_body end |
#frame(type = nil) ⇒ Object
255 256 257 258 259 |
# File 'lib/html/mixin/attribute_handler.rb', line 255 def frame(type = nil) @frame ||= nil self.frame = type if type @frame end |
#frame=(type) ⇒ Object
261 262 263 264 265 266 |
# File 'lib/html/mixin/attribute_handler.rb', line 261 def frame=(type) valid = %w/border void above below hsides lhs rhs vsides box/ raise ArgumentError unless valid.include?(type.downcase) @frame = type modify_html("frame", @frame) end |
#height(num = nil) ⇒ Object
268 269 270 271 272 |
# File 'lib/html/mixin/attribute_handler.rb', line 268 def height(num = nil) @height ||= nil self.height = num if num @height end |
#height=(num) ⇒ Object
274 275 276 277 278 |
# File 'lib/html/mixin/attribute_handler.rb', line 274 def height=(num) raise ArgumentError if num.to_i < 0 @height = num.to_i modify_html("height", @height) end |
#hspace(num = nil) ⇒ Object
280 281 282 283 284 |
# File 'lib/html/mixin/attribute_handler.rb', line 280 def hspace(num = nil) @hspace ||= nil self.hspace = num if num @hspace end |
#hspace=(num) ⇒ Object
286 287 288 289 290 |
# File 'lib/html/mixin/attribute_handler.rb', line 286 def hspace=(num) raise ArgumentError if num.to_i < 0 @hspace = num.to_i modify_html("hspace", @hspace) end |
#nowrap(bool = nil) ⇒ Object
292 293 294 295 296 |
# File 'lib/html/mixin/attribute_handler.rb', line 292 def nowrap(bool = nil) @nowrap ||= nil self.nowrap = bool if bool @nowrap end |
#nowrap=(bool) ⇒ Object
298 299 300 301 302 303 304 |
# File 'lib/html/mixin/attribute_handler.rb', line 298 def nowrap=(bool) unless bool.kind_of?(TrueClass) || bool.kind_of?(FalseClass) raise TypeError end @nowrap = bool modify_html("nowrap", @nowrap) end |
#rowspan(num = nil) ⇒ Object
306 307 308 309 310 |
# File 'lib/html/mixin/attribute_handler.rb', line 306 def rowspan(num = nil) @rowspan ||= nil self.rowspan = num if num @rowspan end |
#rowspan=(num) ⇒ Object
312 313 314 315 316 |
# File 'lib/html/mixin/attribute_handler.rb', line 312 def rowspan=(num) raise ArgumentError if num.to_i < 0 @rowspan = num.to_i modify_html("rowspan", @rowspan) end |
#rules(edges = nil) ⇒ Object
318 319 320 321 322 |
# File 'lib/html/mixin/attribute_handler.rb', line 318 def rules(edges = nil) @rules ||= nil self.rules = edges if edges @rules end |
#rules=(edges) ⇒ Object
324 325 326 327 328 329 |
# File 'lib/html/mixin/attribute_handler.rb', line 324 def rules=(edges) valid = %w/all groups rows cols none/ raise ArgumentError unless valid.include?(edges.to_s.downcase) @rules = edges modify_html("rules", @rules) end |
#span(num = nil) ⇒ Object
331 332 333 334 335 |
# File 'lib/html/mixin/attribute_handler.rb', line 331 def span(num = nil) @span ||= nil self.span = num if num @span end |
#span=(num) ⇒ Object
337 338 339 340 341 |
# File 'lib/html/mixin/attribute_handler.rb', line 337 def span=(num) raise ArgumentError if num.to_i < 0 @span = num.to_i modify_html("span", @span) end |
#style(string = nil) ⇒ Object
343 344 345 346 347 |
# File 'lib/html/mixin/attribute_handler.rb', line 343 def style(string = nil) @style ||= nil self.style = string if string @style end |
#style=(string) ⇒ Object
349 350 351 352 |
# File 'lib/html/mixin/attribute_handler.rb', line 349 def style=(string) @style = string.to_s modify_html("style", @style) end |
#summary(string = nil) ⇒ Object
354 355 356 357 358 |
# File 'lib/html/mixin/attribute_handler.rb', line 354 def summary(string = nil) @summary ||= nil self.summary = string if string @summary end |
#summary=(string) ⇒ Object
360 361 362 363 |
# File 'lib/html/mixin/attribute_handler.rb', line 360 def summary=(string) @summary = string.to_s modify_html("summary", @summary) end |
#valign(position = nil) ⇒ Object
365 366 367 368 369 |
# File 'lib/html/mixin/attribute_handler.rb', line 365 def valign(position = nil) @valign ||= nil self.valign = position if position @valign end |
#valign=(position) ⇒ Object
371 372 373 374 375 376 |
# File 'lib/html/mixin/attribute_handler.rb', line 371 def valign=(position) valid = %w/top center bottom baseline/ raise ArgumentError unless valid.include?(position.to_s.downcase) @valign = position modify_html("valign", @valign) end |
#vspace(num = nil) ⇒ Object
378 379 380 381 382 |
# File 'lib/html/mixin/attribute_handler.rb', line 378 def vspace(num = nil) @vspace ||= nil self.vspace = num if num @vspace end |
#vspace=(num) ⇒ Object
384 385 386 387 388 |
# File 'lib/html/mixin/attribute_handler.rb', line 384 def vspace=(num) raise ArgumentError if num.to_i < 0 @vspace = num.to_i modify_html("vspace", @vspace) end |
#width(num = nil) ⇒ Object
390 391 392 393 394 |
# File 'lib/html/mixin/attribute_handler.rb', line 390 def width(num = nil) @width ||= nil self.width = num if num @width end |
#width=(num) ⇒ Object
396 397 398 399 400 401 402 403 404 |
# File 'lib/html/mixin/attribute_handler.rb', line 396 def width=(num) if num.to_s =~ /%/ @width = num else raise ArgumentError if num.to_i < 0 @width = num.to_i end modify_html("width", @width) end |