Class: VORuby::VOTable::V1_0::Link

Inherits:
Base show all
Defined in:
lib/voruby/votable/1.0/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

link = Link.new(

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


678
679
680
# File 'lib/voruby/votable/1.0/votable.rb', line 678

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

Instance Method Details

#actionObject

Retrieve the action. Returns a URI object.



748
749
750
# File 'lib/voruby/votable/1.0/votable.rb', line 748

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/')


755
756
757
# File 'lib/voruby/votable/1.0/votable.rb', line 755

def action=(a)
  @node['action'] = a.to_s
end

#content_roleObject



690
691
692
# File 'lib/voruby/votable/1.0/votable.rb', line 690

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.



696
697
698
# File 'lib/voruby/votable/1.0/votable.rb', line 696

def content_role=(c)
  @node['content-role'] = c.to_s
end

#content_typeObject



700
701
702
# File 'lib/voruby/votable/1.0/votable.rb', line 700

def content_type
  self.node['content-type']
end

#content_type=(c) ⇒ Object

Set the content type (i.e. mimetype).



705
706
707
# File 'lib/voruby/votable/1.0/votable.rb', line 705

def content_type=(c)
  @node['content-type'] = c.to_s
end

#grefObject



738
739
740
# File 'lib/voruby/votable/1.0/votable.rb', line 738

def gref
  self.node['gref']
end

#gref=(g) ⇒ Object



742
743
744
# File 'lib/voruby/votable/1.0/votable.rb', line 742

def gref=(g)
  @node['gref'] = g.to_s
end

#hrefObject

Retrieve the URL. Returns a URI object.



727
728
729
# File 'lib/voruby/votable/1.0/votable.rb', line 727

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/')


734
735
736
# File 'lib/voruby/votable/1.0/votable.rb', line 734

def href=(h)
  @node['href'] = h.to_s
end

#idObject



682
683
684
# File 'lib/voruby/votable/1.0/votable.rb', line 682

def id
  self.node['ID']
end

#id=(i) ⇒ Object



686
687
688
# File 'lib/voruby/votable/1.0/votable.rb', line 686

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.



762
763
764
765
766
767
768
769
770
# File 'lib/voruby/votable/1.0/votable.rb', line 762

def retrieve
  shref = self.href

  if shref
    shref.scheme == 'file' ? File.open(shref.path) : open(shref.to_s)
  else
    nil
  end
end

#titleObject



709
710
711
# File 'lib/voruby/votable/1.0/votable.rb', line 709

def title
  self.node['title']
end

#title=(t) ⇒ Object



713
714
715
# File 'lib/voruby/votable/1.0/votable.rb', line 713

def title=(t)
  @node['title'] = t.to_s
end

#valueObject



717
718
719
# File 'lib/voruby/votable/1.0/votable.rb', line 717

def value
  self.node['value']
end

#value=(v) ⇒ Object



721
722
723
# File 'lib/voruby/votable/1.0/votable.rb', line 721

def value=(v)
  @node['value'] = v.to_s
end