module HTML::Mixin::AttributeHandler
The AttributeHandler
module creates methods for each of the various attributes associated with HTML
tables. In some cases validation is done on the setters.
Public Instance Methods
abbr(string = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 13 def abbr(string = nil) @abbr ||= nil self.abbr = string if string @abbr end
abbr=(string)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 19 def abbr=(string) @abbr = string modify_html('abbr', string) end
align(position = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 24 def align(position = nil) @align ||= nil self.align = position if position @align end
align=(position)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 30 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)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 37 def axis(string = nil) @axis ||= nil self.axis = string if string @axis end
axis=(string)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 43 def axis=(string) @axis = string modify_html('axis', string) end
background(url = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 48 def background(url = nil) @background ||= nil self.background = url if url @background end
background=(url)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 54 def background=(url) raise TypeError unless url.is_a?(String) msg = "'background' is a non-standard extension" warn NonStandardExtensionWarning, msg @background = url modify_html('background', url) end
bgcolor(color = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 62 def bgcolor(color = nil) @bgcolor ||= nil self.bgcolor = color if color @bgcolor end
bgcolor=(color)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 68 def bgcolor=(color) @bgcolor = color modify_html('bgcolor', color) end
border(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 73 def border(num = nil) @border ||= nil self.border = num if num @border end
border=(num)
click to toggle source
Allow either true/false or an integer
# File lib/html/mixin/attribute_handler.rb, line 80 def border=(num) case num when TrueClass modify_html('border', true) when FalseClass # Do nothing else @border = num.to_i modify_html('border', num.to_i) end end
bordercolor(color = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 92 def bordercolor(color = nil) @bordercolor ||= nil self.bordercolor = color if color @bordercolor end
bordercolor=(color)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 98 def bordercolor=(color) @bordercolor = color msg = "'bordercolor' is a non-standard extension" warn NonStandardExtensionWarning, msg modify_html('bordercolor', color) end
bordercolordark(color = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 105 def bordercolordark(color = nil) @bordercolordark ||= nil self.bordercolordark = color if color @bordercolordark end
bordercolordark=(color)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 111 def bordercolordark=(color) @bordercolordark = color msg = "'bordercolordark' is a non-standard extension" warn NonStandardExtensionWarning, msg modify_html('bordercolordark', color) end
bordercolorlight(color = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 118 def bordercolorlight(color = nil) @bordercolorlight ||= nil self.bordercolorlight = color if color @bordercolorlight end
bordercolorlight=(color)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 124 def bordercolorlight=(color) @bordercolorlight = color msg = "'bordercolorlight' is a non-standard extension" warn NonStandardExtensionWarning, msg modify_html('bordercolorlight', @bordercolorlight) end
cellpadding(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 131 def cellpadding(num = nil) @cellpadding ||= nil self.cellpadding = num if num @cellpadding end
cellpadding=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 137 def cellpadding=(num) raise ArgumentError if num.to_i < 0 @cellpadding = num.to_i modify_html('cellpadding', @cellpadding) end
cellspacing(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 143 def cellspacing(num = nil) @cellspacing ||= nil self.cellspacing = num if num @cellspacing end
cellspacing=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 149 def cellspacing=(num) raise ArgumentError if num.to_i < 0 @cellspacing = num.to_i modify_html('cellspacing', @cellspacing) end
char(character = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 155 def char(character = nil) @char ||= nil self.char = character if character @char end
char=(character)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 161 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)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 167 def charoff(offset = nil) @charoff ||= nil self.charoff = offset if offset @charoff end
charoff=(offset)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 173 def charoff=(offset) raise ArgumentError if offset.to_i < 0 @charoff = offset modify_html('charoff', offset) end
class_(klass = nil)
click to toggle source
Returns the CSS class. The trailing underscore is necessary in order to avoid conflict with the ‘class’ keyword.
# File lib/html/mixin/attribute_handler.rb, line 182 def class_(klass = nil) @class ||= nil self.class_ = klass if klass @class end
class_=(klass)
click to toggle source
Returns the CSS class. The trailing underscore is necessary in order to avoid conflict with the ‘class’ keyword.
# File lib/html/mixin/attribute_handler.rb, line 191 def class_=(klass) modify_html('class', klass) @class = klass end
col(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 196 def col(num = nil) @col ||= nil self.col = num if num @col end
col=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 202 def col=(num) raise ArgumentError if num.to_i < 0 @col = num.to_i modify_html('col', @col) end
colspan(span = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 208 def colspan(span = nil) @colspan ||= nil self.colspan = span if span @colspan end
colspan=(span)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 214 def colspan=(span) raise ArgumentError if span.to_i < 0 @colspan = span.to_i modify_html('colspan', @colspan) end
configure(row, col = nil) { |self[col]| ... }
click to toggle source
Allows you to configure various attributes by row or row + column.
# File lib/html/mixin/attribute_handler.rb, line 222 def configure(row, col = nil) if col begin yield self[row][col] rescue NameError msg = "No column to configure in a #{self.class} class" raise ArgumentError, msg end else yield self[row] end end
content(arg = nil, &block)
click to toggle source
Returns the HTML
content (i.e. text).
# File lib/html/mixin/attribute_handler.rb, line 237 def content(arg = nil, &block) case arg when String self.content = Table::Content.new(arg, &block) when Array arg.each do |e| if e.is_a?(Array) row = Table::Row.new e.each { |element| row.push(Table::Content.new(element, &block)) } push(row) else self.content = Table::Content.new(e, &block) end end else self.content = arg if arg end @html_body end
Also aliased as: data
frame(type = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 259 def frame(type = nil) @frame ||= nil self.frame = type if type @frame end
frame=(type)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 265 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)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 272 def height(num = nil) @height ||= nil self.height = num if num @height end
height=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 278 def height=(num) raise ArgumentError if num.to_i < 0 @height = num.to_i modify_html('height', @height) end
hspace(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 284 def hspace(num = nil) @hspace ||= nil self.hspace = num if num @hspace end
hspace=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 290 def hspace=(num) raise ArgumentError if num.to_i < 0 @hspace = num.to_i modify_html('hspace', @hspace) end
nowrap(bool = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 296 def nowrap(bool = nil) @nowrap ||= nil self.nowrap = bool if bool @nowrap end
nowrap=(bool)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 302 def nowrap=(bool) unless bool.is_a?(TrueClass) || bool.is_a?(FalseClass) raise TypeError end @nowrap = bool modify_html('nowrap', @nowrap) end
rowspan(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 310 def rowspan(num = nil) @rowspan ||= nil self.rowspan = num if num @rowspan end
rowspan=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 316 def rowspan=(num) raise ArgumentError if num.to_i < 0 @rowspan = num.to_i modify_html('rowspan', @rowspan) end
rules(edges = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 322 def rules(edges = nil) @rules ||= nil self.rules = edges if edges @rules end
rules=(edges)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 328 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)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 335 def span(num = nil) @span ||= nil self.span = num if num @span end
span=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 341 def span=(num) raise ArgumentError if num.to_i < 0 @span = num.to_i modify_html('span', @span) end
style(string = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 347 def style(string = nil) @style ||= nil self.style = string if string @style end
style=(string)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 353 def style=(string) @style = string.to_s modify_html('style', @style) end
summary(string = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 358 def summary(string = nil) @summary ||= nil self.summary = string if string @summary end
summary=(string)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 364 def summary=(string) @summary = string.to_s modify_html('summary', @summary) end
valign(position = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 369 def valign(position = nil) @valign ||= nil self.valign = position if position @valign end
valign=(position)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 375 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)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 382 def vspace(num = nil) @vspace ||= nil self.vspace = num if num @vspace end
vspace=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 388 def vspace=(num) raise ArgumentError if num.to_i < 0 @vspace = num.to_i modify_html('vspace', @vspace) end
width(num = nil)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 394 def width(num = nil) @width ||= nil self.width = num if num @width end
width=(num)
click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 400 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