Class: VORuby::VOTable::V1_1::Link

Inherits:
Base show all
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

#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) ⇒ Link

Create a new link.

link = Link.new(
  :href => 'http://fits.gsfc.nasa.gov/nrao_data/samples/image/swp05569slg.fits',
  :content_type => 'image/fits'
)


704
705
706
# File 'lib/voruby/votable/1.1/votable.rb', line 704

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

Instance Method Details

#actionObject

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_roleObject



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_typeObject



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

#grefObject

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

#hrefObject

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

#idObject



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

#retrieveObject

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

#titleObject



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

#valueObject



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