Class: VORuby::VOTable::V1_1::Tr

Inherits:
Base show all
Defined in:
lib/voruby/votable/1.1/votable.rb

Overview

A row of data in a TableData.

Constant Summary collapse

ELEMENT_NAME =
'TR'

Instance Attribute Summary

Attributes inherited from XML::Object::Base

#node

Instance Method Summary collapse

Methods inherited from Base

#==, element_name, #get_element, #xpath_for

Methods inherited from XML::Object::Base

#==, element_name, from_file, #to_s

Constructor Details

#initialize(defn = nil) ⇒ Tr

Create a new row of data.

tr = Tr.new(:tds => [Td.new()])


1984
1985
1986
# File 'lib/voruby/votable/1.1/votable.rb', line 1984

def initialize(defn=nil)
  super(defn)
end

Instance Method Details

#tdsObject

Retrieve the table data elements in the row. Returns a HomogeneousNodeList.



1990
1991
1992
# File 'lib/voruby/votable/1.1/votable.rb', line 1990

def tds
  HomogeneousNodeList.new(self.node, xpath_for(Td), Td)
end

#tds=(columns) ⇒ Object

Set the data elements of the row.

tr.tds = [Td.new(), ...]


1996
1997
1998
# File 'lib/voruby/votable/1.1/votable.rb', line 1996

def tds=(columns)
  self.tds.replace(columns)
end

#to_htmlObject

Convert a table row to HTML.

tr = Tr.new(:tds => [Td.new(:text => 'hello'), Td.new(:text => 'world')])
puts tr.to_html # => 
  <tr>
    <td>hello</td>
    <td>world</td>
  </tr>


2007
2008
2009
2010
2011
2012
2013
2014
2015
# File 'lib/voruby/votable/1.1/votable.rb', line 2007

def to_html
  builder = Builder::XmlMarkup.new(:indent => 2, :margin => 4)
  
  builder.tr { |tr|
    self.tds.each do |column|
      tr << column.to_html
    end
  }
end