Class: VORuby::VOTables::VOTable::Meta::Table
- Defined in:
- lib/voruby/votables/meta.rb,
lib/voruby/votables/transforms.rb,
lib/voruby/votables/rexml_parser.rb,
lib/voruby/votables/libxml_parser.rb
Overview
A class representing the standard VOTable TABLE element.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nrows ⇒ Object
readonly
Returns the value of attribute nrows.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#ucd ⇒ Object
readonly
Returns the value of attribute ucd.
-
#uType ⇒ Object
readonly
Returns the value of attribute uType.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, id = nil, ucd = nil, utype = nil, ref = nil, nrows = nil, description = nil, fields = [], params = [], groups = [], links = [], data = nil) ⇒ Table
constructor
- name:
-
The name of the table.
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, id = nil, ucd = nil, utype = nil, ref = nil, nrows = nil, description = nil, fields = [], params = [], groups = [], links = [], data = nil) ⇒ Table
- name:
-
The name of the table.
- id:
-
The id of the table.
- ucd:
-
A UCD describing the table (Type: Type::UCDType).
- utype:
-
A unique type describing the table.
- ref:
-
A reference to another table.
- nrows:
-
The number of rows in the table (Type: Type::NonNegativeInteger)
- description:
-
A description of the table (Type: Meta::Description)
- fields:
-
A list of fields associated with the table (Type: Meta::Field).
- params:
-
A list of parameters associated with the table (Type: Meta::Param).
- groups:
-
A list of groups associated with the table (Type: Meta::Group).
- links:
-
A list of links associated with the table (Type: Meta::Link).
- data:
-
The actual data associated with the table (Type: DATA::Data).
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'lib/voruby/votables/meta.rb', line 535 def initialize(name=nil, id=nil, ucd=nil, utype=nil, ref=nil, nrows=nil, description=nil, fields=[], params=[], groups=[], links=[], data=nil) @name = name @id = id Misc::TypeCheck.new(ucd, Type::UCDType).check() @ucd = ucd @utype = utype @ref = ref Misc::TypeCheck.new(nrows, Type::NonNegativeInteger).check() @nrows = nrows Misc::TypeCheck.new(description, Meta::Description).check() @description = description fields.each{ |field| Misc::TypeCheck.new(field, Meta::Field).check() } @fields = fields params.each{ |param| Misc::TypeCheck.new(param, Meta::Param).check() } @params = params groups.each{ |group| Misc::TypeCheck.new(group, Meta::Group).check() } @groups = groups links.each{ |link| Misc::TypeCheck.new(link, Meta::Link).check() } @links = links Misc::TypeCheck.new(data, Data::Data).check() @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def data @data end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def description @description end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def fields @fields end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def groups @groups end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def id @id end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def links @links end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def name @name end |
#nrows ⇒ Object (readonly)
Returns the value of attribute nrows.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def nrows @nrows end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def params @params end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def ref @ref end |
#ucd ⇒ Object (readonly)
Returns the value of attribute ucd.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def ucd @ucd end |
#uType ⇒ Object (readonly)
Returns the value of attribute uType.
508 509 510 |
# File 'lib/voruby/votables/meta.rb', line 508 def uType @uType end |
Class Method Details
.from_soap_obj(mtables) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/voruby/votables/transforms.rb', line 134 def self.from_soap_obj(mtables) mtables = [mtables] if !mtables.respond_to?(:each) tables = [] mtables.each do |mtable| ucd_txt = VOTable::_find_attr_value(mtable.__xmlattr, 'ucd') nrows_txt = VOTable::_find_attr_value(mtable.__xmlattr, 'nrows') tables.push(Table.new( VOTable::_find_attr_value(mtable.__xmlattr, 'name'), VOTable::_find_attr_value(mtable.__xmlattr, 'ID'), (ucd_txt == nil)? nil: Type::UCDType.new(ucd_txt), VOTable::_find_attr_value(mtable.__xmlattr, 'utype'), VOTable::_find_attr_value(mtable.__xmlattr, 'ref'), (nrows_txt == nil)? nil: Type::NonNegativeInteger.new(nrows_txt.to_i), (mtable.respond_to?(:dESCRIPTION))? Description.from_soap_obj(mtable.dESCRIPTION): nil, (mtable.respond_to?(:fIELD))? Field.from_soap_obj(mtable.fIELD): [], (mtable.respond_to?(:pARAM))? Param.from_soap_obj(mtable.pARAM): [], (mtable.respond_to?(:gROUP))? Group.from_soap_obj(mtable.gROUP): [], (mtable.respond_to?(:lINK))? Link.from_soap_obj(mtable.lINK): [], (mtable.respond_to?(:dATA))? Data::Data.from_soap_obj(mtable.dATA): nil )) end tables end |
.from_xml(node) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/voruby/votables/rexml_parser.rb', line 201 def self.from_xml(node) # Attributes id = node.attributes['ID'] if node.attributes['ID'] name = node.attributes['name'] if node.attributes['name'] ref = node.attributes['ref'] if node.attributes['ref'] ucd = Type::UCDType.new(node.attributes['ucd']) if node.attributes['ucd'] utype = node.attributes['utype'] if node.attributes['utype'] nrows = Type::NonNegativeInteger.new(node.attributes['nrows'].to_i) if node.attributes['nrows'] # Elements description = Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION'] fields = [] node.elements.each('FIELD'){ |fieldNode| fields.push(Meta::Field.from_xml(fieldNode)) } params = [] node.elements.each('PARAM'){ |paramNode| params.push(Meta::Param.from_xml(paramNode)) } groups = [] node.elements.each('GROUP'){ |groupNode| params.push(Meta::Group.from_xml(groupNode)) } links = [] node.elements.each('LINK'){ |linkNode| params.push(Meta::Link.from_xml(linkNode)) } data = Data::Data.from_xml(node.elements.to_a('DATA').first) if node.elements['DATA'] return self.new(name, id, ucd, utype, ref, nrows, description, fields, params, groups, links, data) end |
Instance Method Details
#to_s ⇒ Object
578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'lib/voruby/votables/meta.rb', line 578 def to_s fields = @fields.each{|x| x.to_s}.join('|') params = @params.each{|x| x.to_s}.join('|') groups = @groups.each{|x| x.to_s}.join('|') links = @links.each{|x| x.to_s}.join('|') "{name=#{@name};id=#{@id};ucd=#{@ucd};utype=#{@utype};ref=#{@ref};" + "nrows=#{@nrows};description=#{@description};" + "fields=#{fields};" + "params=#{params};" + "groups=#{groups};" + "links=#{links};" + "data=#{@data}}" end |