Rserve::REXP::Integer

Constants

NA

Attributes

payload[R]

Public Class Methods

new(data, attrs=nil) click to toggle source
# File lib/rserve/rexp/integer.rb, line 7
def initialize(data, attrs=nil)
  @payload=case data
  when Integer
    [data]
  when Numeric
    [data.to_i]
  when Array
    data
  else
    raise ArgumentError, "Should be Numeric or Array"
  end
  super(attrs)
end

Public Instance Methods

as_doubles() click to toggle source
# File lib/rserve/rexp/integer.rb, line 32
def as_doubles
  @payload.map(&:to_f)
end
as_integers() click to toggle source
# File lib/rserve/rexp/integer.rb, line 29
def as_integers
  @payload
end
as_strings() click to toggle source
# File lib/rserve/rexp/integer.rb, line 35
def as_strings
  @payload.map(&:to_s)
end
integer?() click to toggle source
# File lib/rserve/rexp/integer.rb, line 23
def integer?
  true
end
length() click to toggle source
# File lib/rserve/rexp/integer.rb, line 20
def length
  payload.length
end
na?(value=nil) click to toggle source
# File lib/rserve/rexp/integer.rb, line 39
def na?(value=nil)
  return value == NA unless value.nil?
  @payload.map {|v| v==NA}
end
numeric?() click to toggle source
# File lib/rserve/rexp/integer.rb, line 26
def numeric?
  true
end
to_debug_string() click to toggle source
# File lib/rserve/rexp/integer.rb, line 43
def to_debug_string
  t=super
  t << "{"  << @payload.map(&:to_s).join(",") << "}"
end
to_ruby_internal() click to toggle source
# File lib/rserve/rexp/integer.rb, line 47
def to_ruby_internal
  if dim
    if dim.size==2
      as_matrix
    else
      as_nested_array
    end
  else
    super
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.