Sha256: d29a920ade9dc6d1018168b1bb0f4d26ed47d5f3d1f4e0c779eca0ec0385645c

Contents?: true

Size: 784 Bytes

Versions: 6

Compression:

Stored size: 784 Bytes

Contents

module RubySL
  module Socket
    module Foreign
      class Linger < Rubinius::FFI::Struct
        config('rbx.platform.linger', :l_onoff, :l_linger)

        def self.from_string(string)
          linger = new

          linger.pointer.write_string(string, string.bytesize)

          linger
        end

        def on_off
          self[:l_onoff]
        end

        def linger
          self[:l_linger].to_i
        end

        def on_off=(value)
          if value.is_a?(Integer)
            self[:l_onoff] = value
          else
            self[:l_onoff] = value ? 1 : 0
          end
        end

        def linger=(value)
          self[:l_linger] = value
        end

        def to_s
          pointer.read_string(pointer.total)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysl-socket-2.2.1 lib/rubysl/socket/foreign/linger.rb
rubysl-socket-2.2 lib/rubysl/socket/foreign/linger.rb
rubysl-socket-2.1.3 lib/rubysl/socket/foreign/linger.rb
rubysl-socket-2.1.2 lib/rubysl/socket/foreign/linger.rb
rubysl-socket-2.1.1 lib/rubysl/socket/foreign/linger.rb
rubysl-socket-2.1.0 lib/rubysl/socket/foreign/linger.rb