Class: VORuby::VOTables::VOTable::Meta::Link

Inherits:
Object
  • Object
show all
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 LINK element.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(href = nil, value = nil, title = nil, action = nil, id = nil, content_type = nil, content_role = nil, gref = nil) ⇒ Link

href:

The URI of the link (Type: Type::AnyURI).

value:

The actual value of the link.

title:

The title of the link.

action:

The action associated with the link (Type: Type::AnyURI).

id:

An ID to assign to the link.

content_type:

The content Type of the linked to media.

content_role:

The content role of the linked to media (Type: Type::ContentRole)

gref:

The GLU reference.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/voruby/votables/meta.rb', line 108

def initialize(href=nil, value=nil, title=nil, action=nil,
 		 id=nil, content_type=nil, content_role=nil, gref=nil)
	
Misc::TypeCheck.new(href, Type::AnyURI).check()
@href = href
				
@value = value
@title = title
	
Misc::TypeCheck.new(action, Type::AnyURI).check()
@action = action
	
@content_type = content_type
	
Misc::TypeCheck.new(content_role, Type::ContentRole).check()
@content_role = content_role
				
@id = id
	
@gref = gref
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def action
  @action
end

#content_roleObject (readonly)

Returns the value of attribute content_role.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def content_role
  @content_role
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def content_type
  @content_type
end

#grefObject (readonly)

Returns the value of attribute gref.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def gref
  @gref
end

#hrefObject (readonly)

Returns the value of attribute href.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def href
  @href
end

#idObject (readonly)

Returns the value of attribute id.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def title
  @title
end

#valueObject (readonly)

Returns the value of attribute value.



89
90
91
# File 'lib/voruby/votables/meta.rb', line 89

def value
  @value
end

Class Method Details

.from_soap_obj(mlinks) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/voruby/votables/transforms.rb', line 254

def self.from_soap_obj(mlinks)
  mlinks = [mlinks] if !mlinks.respond_to?(:each)

   links = []
   mlinks.each do |mlink|
     href_txt = VOTable::_find_attr_value(mlink.__xmlattr, 'href')
     action_txt = VOTable::_find_attr_value(mlink.__xmlattr, 'action')
     content_role_txt = VOTable::_find_attr_value(mlink.__xmlattr, 'content-role')

     links.push(Link.new(
       (href_txt == nil)? nil: VOTABLE::Type::AnyURI.new(href_txt),
       VOTable::_find_attr_value(mlink.__xmlattr, 'value'),
       VOTable::_find_attr_value(mlink.__xmlattr, 'title'),
       (action_txt == nil)? nil: VOTABLE::Type::AnyURI.new(action_txt),
       VOTable::_find_attr_value(mlink.__xmlattr, 'ID'),
       VOTable::_find_attr_value(mlink.__xmlattr, 'content-type'),
       (content_role_txt == nil)? nil: Type::ContentRole.new(content_role_txt),
       VOTable::_find_attr_value(mlink.__xmlattr, 'ghref')
     ))
   end

   links       
end

.from_xml(node) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/voruby/votables/rexml_parser.rb', line 42

def self.from_xml(node)
id = node.attributes['ID']
content_role =
 Type::ContentRole.new(node.attributes['content-role']) if node.attributes['content-role']
content_type = node.attributes['content-type']
title = node.attributes['title']
value = node.attributes['value']
href = Type::AnyURI.new(node.attributes['href']) if node.attributes['href']
gref = node.attributes['gref']
action = Type::AnyURI.new(node.attributes['action']) if node.attributes['action']
	
return self.new(href, value, title, action, id, content_type, content_role, gref)
end

Instance Method Details

#to_sObject



130
131
132
133
134
# File 'lib/voruby/votables/meta.rb', line 130

def to_s
"{href=#{@href};value=#{@value};title=#{@title};action=#{@action};" +
"content-type=#{@content_type};content-role=#{content_role};" +
"id=#{@id}}"
end