Class: Procfs2::ProcNetUdp

Inherits:
ProcItem show all
Includes:
Enumerable
Defined in:
lib/procfs2/proc_net_udp.rb

Constant Summary collapse

LABEL =
:udp

Instance Attribute Summary

Attributes inherited from ProcItem

#_data, #_parent

Instance Method Summary collapse

Methods inherited from ProcItem

#_filename, #_path, #_raw_content, build, #initialize

Constructor Details

This class inherits a constructor from Procfs2::ProcItem

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Procfs2::ProcItem

Instance Method Details

#_load_contentObject



10
11
12
13
14
15
16
17
# File 'lib/procfs2/proc_net_udp.rb', line 10

def _load_content
  @_data = []

  lines = _raw_content.lines
  lines.shift

  @_data = lines.map { |socket_line| ProcNetUdpSocket.build_from_line(socket_line) }
end

#by_id(id) ⇒ Object



19
20
21
# File 'lib/procfs2/proc_net_udp.rb', line 19

def by_id(id)
  @_data.find { |socket| socket.id == id.to_i }
end

#by_inode(inode) ⇒ Object



23
24
25
# File 'lib/procfs2/proc_net_udp.rb', line 23

def by_inode(inode)
  @_data.find { |socket| socket.inode == inode.to_i }
end

#each(&block) ⇒ Object



27
28
29
# File 'lib/procfs2/proc_net_udp.rb', line 27

def each(&block)
  _data&.each(&block)
end