Class: VORuby::ADQL::SelectionList

Inherits:
Object
  • Object
show all
Defined in:
lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb

Overview

List of items to be selected in the Query.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ SelectionList

Returns a new instance of SelectionList.



2125
2126
2127
# File 'lib/voruby/adql/adql.rb', line 2125

def initialize(items)
  self.items = items
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



2123
2124
2125
# File 'lib/voruby/adql/adql.rb', line 2123

def items
  @items
end

Class Method Details

.from_xml(node) ⇒ Object



2144
2145
2146
2147
2148
2149
2150
2151
# File 'lib/voruby/adql/adql.rb', line 2144

def self.from_xml(node)
  item_list = []
  node.elements.each('Item') do |item_node|
    item_list.push(Item.from_xml(item_node))
  end

  return SelectionList.new(item_list)
end

Instance Method Details

#add(attributes) ⇒ Object



2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
# File 'lib/voruby/adql/adql.rb', line 2153

def add(attributes)
  new_item = nil
  if attributes['name'] == AllSelectionItem.value
    new_item = AllSelectionItem.new()
  else
    new_item = ColumnReference.new(attributes['table'],
      attributes['name'], attributes['xpath_name'])
  end
  self.items.push(new_item) if new_item and find(attributes) == nil
end

#find(attributes) ⇒ Object



2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
# File 'lib/voruby/adql/adql.rb', line 2169

def find(attributes)
  self.items().each do |item|
    if !item.is_a?(AllSelectionItem)
      return item if item.name() == attributes['name'] and item.table() == attributes['table']
    elsif item.is_a?(AllSelectionItem)
      return item if AllSelectionItem.value == attributes['name']
    end
  end
  return nil
end

#is_emptyObject



2180
2181
2182
# File 'lib/voruby/adql/adql.rb', line 2180

def is_empty
  self.items().empty?
end

#remove(attributes) ⇒ Object



2164
2165
2166
2167
# File 'lib/voruby/adql/adql.rb', line 2164

def remove(attributes)
  remove_item = find(attributes)
  self.items.delete(remove_item) if remove_item != nil
end

#to_adqlsObject



422
423
424
# File 'lib/voruby/adql/transforms.rb', line 422

def to_adqls
  self.items.collect{|x| x.to_adqls}.join(', ')
end

#to_adqlxObject



426
427
428
429
430
431
432
# File 'lib/voruby/adql/transforms.rb', line 426

def to_adqlx
  selection_list = "<SelectionList>\n"
  selection_list << self.items.collect{|x| x.to_adqlx('Item')}.join("\n")
  selection_list << "\n</SelectionList>\n"

  return selection_list
end

#to_sObject



2139
2140
2141
2142
# File 'lib/voruby/adql/adql.rb', line 2139

def to_s
  items = self.items.collect{|x| x.to_s}.join('|')
  return "{items=#{items}}"
end