Class: VORuby::VOTable::V1_1::Resource
- Inherits:
-
Base
- Object
- XML::Object::Base
- Base
- VORuby::VOTable::V1_1::Resource
- Defined in:
- lib/voruby/votable/1.1/votable.rb
Overview
A description and the data values of some logically independent data structure within the VOTable.
Constant Summary collapse
- ELEMENT_NAME =
'RESOURCE'
Instance Attribute Summary
Attributes inherited from XML::Object::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#coordinate_systems ⇒ Object
Retrieve the coordinate systems (Coosys).
-
#coordinate_systems=(systems) ⇒ Object
Set the coordinate systems (Coosys).
-
#description ⇒ Object
Retrieve the description (Description).
-
#description=(d) ⇒ Object
Set the description (Description).
- #id ⇒ Object
- #id=(i) ⇒ Object
-
#infos ⇒ Object
Retrieve the name-value pairs (Info).
-
#infos=(is) ⇒ Object
Set any name-value pairs.
-
#initialize(defn = nil) ⇒ Resource
constructor
Create a new resource.
-
#links ⇒ Object
Retrieve the links (Link).
-
#links=(lnks) ⇒ Object
Set the links (Link).
- #name ⇒ Object
- #name=(n) ⇒ Object
-
#params ⇒ Object
Retrieve the parameters (Param).
-
#params=(parameters) ⇒ Object
Set the parameters (Param).
-
#resources ⇒ Object
Retrieve sub-resources (Resource).
-
#resources=(res) ⇒ Object
Set sub-resources.
-
#tables ⇒ Object
Retrieve the tables (Table).
-
#tables=(tbls) ⇒ Object
Set the tables (Table).
-
#to_html ⇒ Object
Convert a resource to HTML.
-
#type ⇒ Object
Retrieve the type.
-
#type=(t) ⇒ Object
Set the type.
-
#utype ⇒ Object
Retrieve the utype.
-
#utype=(u) ⇒ Object
Set the utype (i.e. the role of the column in the context of an external data model).
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) ⇒ Resource
535 536 537 |
# File 'lib/voruby/votable/1.1/votable.rb', line 535 def initialize(defn=nil) super(defn) end |
Class Method Details
.serialization_order ⇒ Object
520 521 522 523 524 525 |
# File 'lib/voruby/votable/1.1/votable.rb', line 520 def self.serialization_order [ :description, :infos, :coordinate_systems, :params, :links, :tables, :resources, :id, :name, :type, :utype ] end |
Instance Method Details
#coordinate_systems ⇒ Object
Retrieve the coordinate systems (Coosys). Returns a HomogeneousNodeList.
602 603 604 |
# File 'lib/voruby/votable/1.1/votable.rb', line 602 def coordinate_systems HomogeneousNodeList.new(self.node, xpath_for(Coosys), Coosys) end |
#coordinate_systems=(systems) ⇒ Object
Set the coordinate systems (Coosys).
res.coordinate_systems = [Coosys.new(), ...]
608 609 610 |
# File 'lib/voruby/votable/1.1/votable.rb', line 608 def coordinate_systems=(systems) self.coordinate_systems.replace(systems) end |
#description ⇒ Object
Retrieve the description (Description).
578 579 580 |
# File 'lib/voruby/votable/1.1/votable.rb', line 578 def description get_element(Description) end |
#description=(d) ⇒ Object
Set the description (Description).
res.description = Description.new(:text => 'A fascinating resource')
584 585 586 |
# File 'lib/voruby/votable/1.1/votable.rb', line 584 def description=(d) set_element(Description, d) end |
#id ⇒ Object
547 548 549 |
# File 'lib/voruby/votable/1.1/votable.rb', line 547 def id self.node['ID'] end |
#id=(i) ⇒ Object
551 552 553 |
# File 'lib/voruby/votable/1.1/votable.rb', line 551 def id=(i) @node['ID'] = i.to_s end |
#infos ⇒ Object
Retrieve the name-value pairs (Info). Returns a HomogeneousNodeList.
590 591 592 |
# File 'lib/voruby/votable/1.1/votable.rb', line 590 def infos HomogeneousNodeList.new(self.node, xpath_for(Info), Info) end |
#infos=(is) ⇒ Object
Set any name-value pairs.
res.infos = [Info.new(), ...]
596 597 598 |
# File 'lib/voruby/votable/1.1/votable.rb', line 596 def infos=(is) self.infos.replace(is) end |
#links ⇒ Object
Retrieve the links (Link). Returns a HomogeneousNodeList.
629 630 631 |
# File 'lib/voruby/votable/1.1/votable.rb', line 629 def links HomogeneousNodeList.new(self.node, xpath_for(Link), Link) end |
#links=(lnks) ⇒ Object
Set the links (Link).
res.links = [Link.new(), ...]
635 636 637 |
# File 'lib/voruby/votable/1.1/votable.rb', line 635 def links=(lnks) self.links.replace(lnks) end |
#name ⇒ Object
539 540 541 |
# File 'lib/voruby/votable/1.1/votable.rb', line 539 def name self.node['name'] end |
#name=(n) ⇒ Object
543 544 545 |
# File 'lib/voruby/votable/1.1/votable.rb', line 543 def name=(n) @node['name'] = n.to_s end |
#params ⇒ Object
Retrieve the parameters (Param). Returns a HomogeneousNodeList.
614 615 616 |
# File 'lib/voruby/votable/1.1/votable.rb', line 614 def params HomogeneousNodeList.new(self.node, xpath_for(Param), Param) end |
#params=(parameters) ⇒ Object
Set the parameters (Param).
res.params = [Param.new(), ...]
620 621 622 623 624 625 |
# File 'lib/voruby/votable/1.1/votable.rb', line 620 def params=(parameters) self.params.clear parameters.each do |p| self.params << p end end |
#resources ⇒ Object
Retrieve sub-resources (Resource). Returns a HomogeneousNodeList.
653 654 655 |
# File 'lib/voruby/votable/1.1/votable.rb', line 653 def resources HomogeneousNodeList.new(self.node, xpath_for(Resource), Resource) end |
#resources=(res) ⇒ Object
Set sub-resources.
res.resources = [Resource.new(), ...]
659 660 661 |
# File 'lib/voruby/votable/1.1/votable.rb', line 659 def resources=(res) self.resources.replace(res) end |
#tables ⇒ Object
Retrieve the tables (Table). Returns a HomogeneousNodeList.
641 642 643 |
# File 'lib/voruby/votable/1.1/votable.rb', line 641 def tables HomogeneousNodeList.new(self.node, xpath_for(Table), Table) end |
#tables=(tbls) ⇒ Object
Set the tables (Table).
res.tables = [Table.new(), ....]
647 648 649 |
# File 'lib/voruby/votable/1.1/votable.rb', line 647 def tables=(tbls) self.tables.replace(tbls) end |
#to_html ⇒ Object
Convert a resource to HTML.
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'lib/voruby/votable/1.1/votable.rb', line 664 def to_html builder = Builder::XmlMarkup.new(:indent => 2, :margin => 1) resource_opts = {:class => 'resource'} resource_opts[:id] = self.id if self.id builder.div(resource_opts){ |resource| resource.h3(self.name) if self.name resource.div(self.description.text, :class => 'description') if self.description self.tables.each do |tbl| resource << tbl.to_html end self.resources.each do |res| resource << res.to_html end } end |
#type ⇒ Object
Retrieve the type. A type of ‘meta’ means that the resource is descriptive only (does not contain any actual data in any of its sub-elements).
568 569 570 |
# File 'lib/voruby/votable/1.1/votable.rb', line 568 def type self.node['type'] end |
#type=(t) ⇒ Object
Set the type.
573 574 575 |
# File 'lib/voruby/votable/1.1/votable.rb', line 573 def type=(t) @node['type'] = t.to_s end |
#utype ⇒ Object
Retrieve the utype.
556 557 558 |
# File 'lib/voruby/votable/1.1/votable.rb', line 556 def utype self.node['utype'] end |
#utype=(u) ⇒ Object
Set the utype (i.e. the role of the column in the context of an external data model).
561 562 563 |
# File 'lib/voruby/votable/1.1/votable.rb', line 561 def utype=(u) @node['utype'] = u.to_s end |