Parent

Included Modules

Rserve::Rlist

Public Class Methods

new(data=nil, n=nil) click to toggle source
# File lib/rserve/rlist.rb, line 4
def initialize(data=nil, n=nil)
  @names=nil
  if data.nil?
    super()
  else        
    case data
    when Array
      super(data)
    when Numeric
      super([data])
    else
      raise ArgumentError
    end
  end
  if n
    @names=Array.new(size)
    n.each_index {|i| @names[i]=n[i]} if n.respond_to? :each_index
  end
end

Public Instance Methods

==(o) click to toggle source
# File lib/rserve/rlist.rb, line 34
def ==(o)
  #p "Comparing #{self.inspect} with #{o.inspect} gives #{o.is_a? Rlist and self.data==o.data and self.names==o.names}"
  o.is_a? Rlist and self.data==o.data and self.names==o.names
end
data() click to toggle source

Returns the data, as REXP

# File lib/rserve/rlist.rb, line 31
def data
  self.map {|d| d}
end
keys() click to toggle source
# File lib/rserve/rlist.rb, line 23
def keys
  @names
end
to_a() click to toggle source

Returns the data without names, as Ruby objects

# File lib/rserve/rlist.rb, line 27
def to_a
  self.map {|d| d.to_ruby} 
end
to_ruby() click to toggle source

Returns an Array with module WithNames included

  • Unnamed list: returns an Array

  • Named List: returns a Hash. Every element without explicit name receive as key the number of element, 1-based

# File lib/rserve/rlist.rb, line 48
def to_ruby
  data=to_a
  data.extend WithNames
  data.names=@names
  data
end
to_s() click to toggle source
# File lib/rserve/rlist.rb, line 38
def to_s
  super+"[#{size}]"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.