Class: VORuby::VOTable::V1_1::Link
- Inherits:
-
Base
- Object
- XML::Object::Base
- Base
- VORuby::VOTable::V1_1::Link
- Defined in:
- lib/voruby/votable/1.1/votable.rb
Overview
A link or pointer to other documents or data servers on the Internet through a URI.
Constant Summary collapse
- ELEMENT_NAME =
'LINK'
Instance Attribute Summary
Attributes inherited from XML::Object::Base
Instance Method Summary collapse
-
#action ⇒ Object
Retrieve the action.
-
#action=(a) ⇒ Object
Set the action.
- #content_role ⇒ Object
-
#content_role=(c) ⇒ Object
Set the content role.
- #content_type ⇒ Object
-
#content_type=(c) ⇒ Object
Set the content type (i.e. mimetype).
-
#gref ⇒ Object
DEPRECATED.
-
#gref=(g) ⇒ Object
DEPRECATED.
-
#href ⇒ Object
Retrieve the URL.
-
#href=(h) ⇒ Object
Set the URL.
- #id ⇒ Object
- #id=(i) ⇒ Object
-
#initialize(defn = nil) ⇒ Link
constructor
Create a new link.
-
#retrieve ⇒ Object
Retrieve the link.
- #title ⇒ Object
- #title=(t) ⇒ Object
- #value ⇒ Object
- #value=(v) ⇒ Object
Methods inherited from Base
#==, element_name, #get_element, #xpath_for
Methods inherited from XML::Object::Base
#==, element_name, from_file, #to_s
Constructor Details
Instance Method Details
#action ⇒ Object
Retrieve the action. Returns a URI object.
776 777 778 |
# File 'lib/voruby/votable/1.1/votable.rb', line 776 def action self.node['action'] ? URI.parse(self.node['action']) : nil end |
#action=(a) ⇒ Object
Set the action.
link.action = 'http://www.retrieve-me.com/' # or...
link.action = URI.parse('http://www.retrieve-me.com/')
783 784 785 |
# File 'lib/voruby/votable/1.1/votable.rb', line 783 def action=(a) @node['action'] = a.to_s end |
#content_role ⇒ Object
716 717 718 |
# File 'lib/voruby/votable/1.1/votable.rb', line 716 def content_role self.node['content-role'] end |
#content_role=(c) ⇒ Object
Set the content role. May be one of: query, hints, doc or location.
722 723 724 |
# File 'lib/voruby/votable/1.1/votable.rb', line 722 def content_role=(c) @node['content-role'] = c.to_s end |
#content_type ⇒ Object
726 727 728 |
# File 'lib/voruby/votable/1.1/votable.rb', line 726 def content_type self.node['content-type'] end |
#content_type=(c) ⇒ Object
Set the content type (i.e. mimetype).
731 732 733 |
# File 'lib/voruby/votable/1.1/votable.rb', line 731 def content_type=(c) @node['content-type'] = c.to_s end |
#gref ⇒ Object
DEPRECATED.
765 766 767 |
# File 'lib/voruby/votable/1.1/votable.rb', line 765 def gref self.node['gref'] end |
#gref=(g) ⇒ Object
DEPRECATED.
770 771 772 |
# File 'lib/voruby/votable/1.1/votable.rb', line 770 def gref=(g) @node['gref'] = g.to_s end |
#href ⇒ Object
Retrieve the URL. Returns a URI object.
753 754 755 |
# File 'lib/voruby/votable/1.1/votable.rb', line 753 def href self.node['href'] ? URI.parse(self.node['href']) : nil end |
#href=(h) ⇒ Object
Set the URL.
link.href = 'http://www.noao.edu/' # or...
link.href = URI.parse('http://www.noao.edu/')
760 761 762 |
# File 'lib/voruby/votable/1.1/votable.rb', line 760 def href=(h) @node['href'] = h.to_s end |
#id ⇒ Object
708 709 710 |
# File 'lib/voruby/votable/1.1/votable.rb', line 708 def id self.node['ID'] end |
#id=(i) ⇒ Object
712 713 714 |
# File 'lib/voruby/votable/1.1/votable.rb', line 712 def id=(i) @node['ID'] = i.to_s end |
#retrieve ⇒ Object
Retrieve the link. Understands any URL groked by open-uri (including file://). Returns a File object.
790 791 792 793 794 795 796 797 798 |
# File 'lib/voruby/votable/1.1/votable.rb', line 790 def retrieve shref = self.href if shref shref.scheme == 'file' ? File.open(shref.path) : open(shref.to_s) else nil end end |
#title ⇒ Object
735 736 737 |
# File 'lib/voruby/votable/1.1/votable.rb', line 735 def title self.node['title'] end |
#title=(t) ⇒ Object
739 740 741 |
# File 'lib/voruby/votable/1.1/votable.rb', line 739 def title=(t) @node['title'] = t.to_s end |
#value ⇒ Object
743 744 745 |
# File 'lib/voruby/votable/1.1/votable.rb', line 743 def value self.node['value'] end |
#value=(v) ⇒ Object
747 748 749 |
# File 'lib/voruby/votable/1.1/votable.rb', line 747 def value=(v) @node['value'] = v.to_s end |