Class: VORuby::VOTables::VOTable::Meta::Resource
- 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 RESOURCE element.
Instance Attribute Summary collapse
-
#coosys ⇒ Object
readonly
Returns the value of attribute coosys.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
-
#Type ⇒ Object
readonly
Returns the value of attribute Type.
-
#uType ⇒ Object
readonly
Returns the value of attribute uType.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, id = nil, utype = nil, type = ResourceType.new('results'), description = nil, info = [], coosys = [], params = [], links = [], tables = [], resources = []) ⇒ Resource
constructor
- name:
-
The name of the resource.
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, id = nil, utype = nil, type = ResourceType.new('results'), description = nil, info = [], coosys = [], params = [], links = [], tables = [], resources = []) ⇒ Resource
- name:
-
The name of the resource.
- id:
-
The ID of the resource.
- utype:
-
The unique type of the resource.
- type:
-
The type of resource (Type: Type::ResourceType).
- description:
-
A description of the resource (Type: Meta::Description).
- info:
-
A list of information about the resource (Type: Meta::Info).
- coosys:
-
A list of coordinate systems (Type: Meta::CooSys).
- params:
-
A list of parameters (Type: Meta::Param).
- links:
-
A list of links associated with the resource (Type: Meta::Link).
- tables:
-
A list of tables associated with the resource (Type: Meta::Table).
- resources:
-
A list of subresources (Type: Meta::Resource).
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/voruby/votables/meta.rb', line 621 def initialize(name=nil, id=nil, utype=nil, type=ResourceType.new('results'), description=nil, info=[], coosys=[], params=[], links=[], tables=[], resources=[]) @name = name @id = id @utype = utype Misc::TypeCheck.new(type, Type::ResourceType).check() @type = type Misc::TypeCheck.new(description, Meta::Description).check() @description = description info.each{ |inf| Misc::TypeCheck.new(inf, Meta::Info).check() } @info = info coosys.each{ |sys| Misc::TypeCheck.new(sys, Meta::CooSys).check() } @coosys = coosys params.each{ |param| Misc::TypeCheck.new(param, Meta::Param).check() } @params = params links.each{ |link| Misc::TypeCheck.new(link, Meta::Link).check() } @links = links tables.each{ |table| Misc::TypeCheck.new(table, Meta::Table).check() } @tables = tables resources.each{ |res| Misc::TypeCheck.new(res, Meta::Resource).check() } @resources = resources end |
Instance Attribute Details
#coosys ⇒ Object (readonly)
Returns the value of attribute coosys.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def coosys @coosys end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def info @info end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def links @links end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def params @params end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def resources @resources end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def tables @tables end |
#Type ⇒ Object (readonly)
Returns the value of attribute Type.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def Type @Type end |
#uType ⇒ Object (readonly)
Returns the value of attribute uType.
596 597 598 |
# File 'lib/voruby/votables/meta.rb', line 596 def uType @uType end |
Class Method Details
.from_soap_obj(mresources) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/voruby/votables/transforms.rb', line 107 def self.from_soap_obj(mresources) mresources = [mresources] if !mresources.respond_to?(:each) resources = [] mresources.each do |mres| type_txt = VOTable::_find_attr_value(mres.__xmlattr, 'type') || 'results' resources.push(Resource.new( VOTable::_find_attr_value(mres.__xmlattr, 'name'), VOTable::_find_attr_value(mres.__xmlattr, 'ID'), VOTable::_find_attr_value(mres.__xmlattr, 'utype'), Type::ResourceType.new(type_txt), (mres.respond_to?(:dESCRIPTION))? Description.from_soap_obj(mres.dESCRIPTION): nil, (mres.respond_to?(:iNFO))? Info.from_soap_obj(mres.iNFO): [], (mres.respond_to?(:cOOSYS))? CooSys.from_soap_obj(mres.cOOSYS): [], (mres.respond_to?(:pARAM))? Param.from_soap_obj(mres.pARAM): [], (mres.respond_to?(:lINK))? Link.from_soap_obj(mres.lINK): [], Table.from_soap_obj(mres.tABLE), (mres.respond_to?(:rESOURCE))? Resource.from_soap_obj(mres.rESOURCE): [] )) end resources end |
.from_xml(node) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/voruby/votables/rexml_parser.rb', line 242 def self.from_xml(node) # Attributes name = node.attributes['name'] if node.attributes['name'] id = node.attributes['ID'] if node.attributes['ID'] utype = node.attributes['utype'] if node.attributes['utype'] type = Type::ResourceType.new(node.attributes['type']) if node.attributes['type'] # Elements description = Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION'] info = [] node.elements.each('INFO'){ |infoNode| info.push(Meta::Info.from_xml(infoNode)) } systems = [] node.elements.each('COOSYS'){ |sysNode| systems.push(Meta::CooSys.from_xml(sysNode)) } params = [] node.elements.each('PARAM'){ |paramNode| params.push(Meta::Param.from_xml(paramNode)) } resources = [] node.elements.each('RESOURCE'){ |resNode| resources.push(Meta::Resource.from_xml(resNode)) } links = [] node.elements.each('LINK'){ |linkNode| links.push(Meta::Link.from_xml(linkNode)) } tables = [] node.elements.each('TABLE'){ |tblNode| tables.push(Meta::Table.from_xml(tblNode)) } return self.new(name, id, utype, type, description, info, systems, params, links, tables, resources) end |
Instance Method Details
#to_s ⇒ Object
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'lib/voruby/votables/meta.rb', line 666 def to_s info = @info.each{|x| x.to_s}.join('|') coosys = @coosys.each{|x| x.to_s}.join('|') params = @params.each{|x| x.to_s}.join('|') links = @links.each{|x| x.to_s}.join('|') tables = @tables.each{|x| x.to_s}.join('|') resources = @resources.each{|x| x.to_s}.join('|') "{name=#{@name};id=#{@id};utype=#{@utype};type=#{@type};" + "description=#{@description};" + "info=#{info};" + "coosys=#{coosys};" + "params=#{params};" + "links=#{links};" + "tables=#{tables};" + "resources=#{resources}}" end |