module HTML::Mixin::AttributeHandler

Public Instance Methods

abbr(string = nil) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 10
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 16
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 21
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 34
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 40
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 45
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 59
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 65
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 70
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 88
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 94
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 101
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 107
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 114
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 120
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 127
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 133
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 139
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 145
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 151
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 163
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 169
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 178
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 187
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 192
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 198
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 204
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 210
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 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) click to toggle source

Returns the HTML content (i.e. text).

# 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
Also aliased as: data
data(arg = nil, &block)
Alias for: content
frame(type = nil) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 255
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 268
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 274
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 280
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 286
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 292
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 306
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 312
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 318
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 331
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 337
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 343
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 349
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 354
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 360
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 365
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 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) click to toggle source
# File lib/html/mixin/attribute_handler.rb, line 378
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 384
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 390
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 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