Class: Rri::RubyConverters::DoubleConverter

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

Overview

Converter for R Integers

Convert R double to ruby Fixnum

Instance Method Summary collapse

Instance Method Details

#convert(rexp) ⇒ Array

Convert R object to ruby format

If the R object is a double, converts it into a ruby Float

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/double_converter.rb', line 18

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