Class: Netlink::NlMsgError

Inherits:
Object
  • Object
show all
Defined in:
lib/netlink/nlmsghdr.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code, orig_header) ⇒ NlMsgError

Returns a new instance of NlMsgError.



56
57
58
59
# File 'lib/netlink/nlmsghdr.rb', line 56

def initialize(error_code, orig_header)
  @error_code = error_code
  @orig_header = orig_header
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



48
49
50
# File 'lib/netlink/nlmsghdr.rb', line 48

def error_code
  @error_code
end

#orig_headerObject (readonly)

Returns the value of attribute orig_header.



48
49
50
# File 'lib/netlink/nlmsghdr.rb', line 48

def orig_header
  @orig_header
end

Class Method Details

.from_string(msg) ⇒ Object



50
51
52
53
54
# File 'lib/netlink/nlmsghdr.rb', line 50

def self.from_string(msg)
  error_code = msg[0, 4].unpack1('L')
  orig_header = NlMsgHdr.from_string(msg[4, NlMsgHdr::SIZE])
  new(error_code, orig_header)
end

Instance Method Details

#ack?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/netlink/nlmsghdr.rb', line 65

def ack?
  @error_code.zero?
end

#to_sObject



61
62
63
# File 'lib/netlink/nlmsghdr.rb', line 61

def to_s
  [@error_code].pack('L') << @orig_header.to_s
end