Class: RinRuby::R_Integer

Inherits:
R_DataType show all
Defined in:
lib/rinruby.rb

Constant Summary collapse

ID =
RinRuby_Type_Integer

Class Method Summary collapse

Methods inherited from R_DataType

===

Class Method Details

.convertable?(value) ⇒ Boolean

Returns:

  • (Boolean)


700
701
702
703
704
705
# File 'lib/rinruby.rb', line 700

def convertable?(value)
  value.all?{|x|
    (x == nil) ||
        (x.kind_of?(Integer) && (x >= RinRuby_Min_R_Integer) && (x <= RinRuby_Max_R_Integer))
  }
end

.receive(io) ⇒ Object



713
714
715
716
717
718
# File 'lib/rinruby.rb', line 713

def receive(io)
  length = io.read(4).unpack('l').first
  io.read(4 * length).unpack("l*").collect{|v|
    (v == RinRuby_NA_R_Integer) ? nil : v
  }
end

.send(value, io) ⇒ Object



706
707
708
709
710
711
712
# File 'lib/rinruby.rb', line 706

def send(value, io)
  # Integer format: size, data, ...
  io.write([value.size].pack('l'))
  value.each{|x|
    io.write([(x == nil) ? RinRuby_NA_R_Integer : x].pack('l'))
  }
end