Class: RinRuby::R_Logical

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

Constant Summary collapse

ID =
RinRuby_Type_Logical
CONVERT_TABLE =

Class Method Summary collapse

Methods inherited from R_DataType

===

Class Method Details

.convertable?(value) ⇒ Boolean

Returns:

  • (Boolean)


678
679
680
# File 'lib/rinruby.rb', line 678

def convertable?(value)
  value.all?{|x| [true, false, nil].include?(x)}
end

.receive(io) ⇒ Object



688
689
690
691
692
693
# File 'lib/rinruby.rb', line 688

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 > 0)
  }
end

.send(value, io) ⇒ Object



681
682
683
684
685
686
687
# File 'lib/rinruby.rb', line 681

def send(value, io)
  # Logical format: size, data, ...
  io.write([value.size].pack('l'))
  value.each{|x|
    io.write(CONVERT_TABLE[x])
  }
end