Class: Socket::Option

Inherits:
Object
  • Object
show all
Defined in:
mrbgems/mruby-socket/mrblib/socket.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(family, level, optname, data) ⇒ Option

Returns a new instance of Option



579
580
581
582
583
584
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 579

def initialize(family, level, optname, data)
  @family  = family
  @level   = level
  @optname = optname
  @data    = data
end

Instance Attribute Details

#dataObject (readonly)

def self.linger(family, level, optname, integer) end



597
598
599
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 597

def data
  @data
end

#familyObject (readonly)

def self.linger(family, level, optname, integer) end



597
598
599
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 597

def family
  @family
end

#levelObject (readonly)

def self.linger(family, level, optname, integer) end



597
598
599
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 597

def level
  @level
end

#optnameObject (readonly)

def self.linger(family, level, optname, integer) end



597
598
599
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 597

def optname
  @optname
end

Class Method Details

.bool(family, level, optname, bool) ⇒ Object



586
587
588
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 586

def self.bool(family, level, optname, bool)
  self.new(family, level, optname, [(bool ? 1 : 0)].pack('i'))
end

.int(family, level, optname, integer) ⇒ Object



590
591
592
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 590

def self.int(family, level, optname, integer)
  self.new(family, level, optname, [integer].pack('i'))
end

Instance Method Details

#boolObject



599
600
601
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 599

def bool
  @data.unpack('i')[0] != 0
end

#inspectObject



603
604
605
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 603

def inspect
  "#<Socket::Option: family:#{@family} level:#{@level} optname:#{@optname} #{@data.inspect}>"
end

#intObject



607
608
609
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 607

def int
  @data.unpack('i')[0]
end

#lingerObject



611
612
613
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 611

def linger
  raise NotImplementedError.new
end

#unpack(template) ⇒ Object



615
616
617
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 615

def unpack(template)
  raise NotImplementedError.new
end