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.



2177
2178
2179
# File 'lib/voruby/adql/adql.rb', line 2177

def initialize(items)
  self.items = items
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



2175
2176
2177
# File 'lib/voruby/adql/adql.rb', line 2175

def items
  @items
end

Class Method Details

.from_xml(node) ⇒ Object



2196
2197
2198
2199
2200
2201
2202
2203
# File 'lib/voruby/adql/adql.rb', line 2196

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



2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
# File 'lib/voruby/adql/adql.rb', line 2205

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



2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
# File 'lib/voruby/adql/adql.rb', line 2221

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



2232
2233
2234
# File 'lib/voruby/adql/adql.rb', line 2232

def is_empty
  self.items().empty?
end

#remove(attributes) ⇒ Object



2216
2217
2218
2219
# File 'lib/voruby/adql/adql.rb', line 2216

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



2191
2192
2193
2194
# File 'lib/voruby/adql/adql.rb', line 2191

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