Class: Rri::RubyConverters::IntegerConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/rri/ruby_converters/integer_converter.rb

Overview

Converter for R Integers

Convert R integer to ruby Fixnum

Instance Method Summary collapse

Instance Method Details

#convert(rexp) ⇒ Array

Convert R object to ruby format

If the R object is an integer, converts it into a ruby Fixnum

Parameters:

  • rexp (REXP)

    rexp to convert

Returns:

  • (Array)

    an array of size 2 where first element is a boolean indicating succes, and the second element is the converted object if conversion successful



18
19
20
21
22
23
24
# File 'lib/rri/ruby_converters/integer_converter.rb', line 18

def convert(rexp)
  if rexp.kind_of?(REXP) and rexp.isInteger and rexp.length == 1
    [true, rexp.asInteger]
  else
    [false, nil]
  end
end