Class: Y2Network::InterfaceType
- Inherits:
-
Object
- Object
- Y2Network::InterfaceType
- Extended by:
- Yast::I18n
- Includes:
- Yast::I18n
- Defined in:
- src/lib/y2network/interface_type.rb
Overview
This class represents the interface types which are supported. Class have helpers to check if given type is what needed. It check name and also short name:
Constant Summary collapse
- ETHERNET =
Ethernet card, integrated or attached
new(N_("Ethernet"), "eth")
- WIRELESS =
Wireless card, integrated or attached
new(N_("Wireless"), "wlan")
- INFINIBAND =
Infiniband card
new(N_("Infiniband"), "ib")
- INFINIBAND_CHILD =
Infiniband card child device. Used in IPoIB (IP-over-InfiniBand)
new(N_("Infiniband Child"), "ibchild")
- BONDING =
Bonding device
new(N_("Bonding"), "bond")
- BRIDGE =
bridge device
new(N_("Bridge"), "br")
- DUMMY =
virtual dummy device provided by dummy kernel module
new(N_("Dummy"), "dummy")
- VLAN =
Virtual LAN
new(N_("VLAN"), "vlan")
- TUN =
TUN virtual device provided by kernel, operates on layer3 carrying IP packagets
new(N_("TUN"), "tun")
- TAP =
TAP virtual device provided by kernel, operates on layer2 carrying Ethernet frames
new(N_("TAP"), "tap")
- USB =
ethernet over usb device provided by usbnet kernel module. Do not confuse with ethernet card attached to USB slot as it is common ETHERNET type.
new(N_("USB"), "usb")
- QETH =
device using qeth device driver for s390. Can operate on layer2 or layer3.
new(N_("QETH"), "qeth")
- LCS =
LAN-Channel-Station (LCS) network devices. S390 specific.
new(N_("LCS"), "lcs")
- HSI =
HiperSockets s390 network device
new(N_("HSI"), "hsi")
- CTC =
Channel To Channel. S390 specific
new(N_("CTC"), "ctc")
- FICON =
FICON-attached direct access storage devices. s390 specific
new(N_("FICON"), "ficon")
- PPP =
Point-to-Point Protocol
new(N_("Point-to-Point Protocol"), "ppp")
- IPIP =
Ip in Ip protocol
new(N_("Ip-in-ip"), "ipip")
- IPV6TNL =
IPv6 Tunnel interface
new(N_("IPv6 Tunnel"), "ip6tnl")
- SIT =
IPv6 over IPv4
new(N_("IPv6 over IPv4 Tunnel"), "sit")
- GRE =
IP over IPv4
new(N_("IP over IPv4 Tunnel"), "gre")
- IRDA =
Infrared
new(N_("Infrared"), "irda")
- LO =
Loopback
new(N_("Loopback"), "lo")
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Returns type name.
-
#short_name ⇒ String
readonly
Returns type's short name.
Class Method Summary collapse
-
.all ⇒ Array<InterfaceType>
Returns all the existing types.
-
.from_short_name(short_name) ⇒ InterfaceType?
Returns the interface type with a given short name.
Instance Method Summary collapse
-
#class_name ⇒ String
Returns name for specialized class for this type e.g.
-
#file_name ⇒ String
Returns name for file without suffix for this type e.g.
-
#initialize(name, short_name) ⇒ InterfaceType
constructor
Constructor.
- #method_missing(method_name, *arguments, &block) ⇒ Object
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
-
#to_human_string ⇒ String
Returns the translated name.
Constructor Details
#initialize(name, short_name) ⇒ InterfaceType
Constructor
62 63 64 65 66 |
# File 'src/lib/y2network/interface_type.rb', line 62 def initialize(name, short_name) textdomain "network" @name = name @short_name = short_name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'src/lib/y2network/interface_type.rb', line 97 def method_missing(method_name, *arguments, &block) return super unless respond_to_missing?(method_name) if !arguments.empty? raise ArgumentError, "no params are accepted for method #{method_name}" end target_name = method_name.to_s[0..-2] [name.downcase, short_name].include?(target_name) end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns type name
53 54 55 |
# File 'src/lib/y2network/interface_type.rb', line 53 def name @name end |
#short_name ⇒ String (readonly)
Returns type's short name
55 56 57 |
# File 'src/lib/y2network/interface_type.rb', line 55 def short_name @short_name end |
Class Method Details
.all ⇒ Array<InterfaceType>
Returns all the existing types
37 38 39 40 41 |
# File 'src/lib/y2network/interface_type.rb', line 37 def all @types ||= InterfaceType.constants .map { |c| InterfaceType.const_get(c) } .select { |c| c.is_a?(InterfaceType) } end |
.from_short_name(short_name) ⇒ InterfaceType?
Returns the interface type with a given short name
47 48 49 |
# File 'src/lib/y2network/interface_type.rb', line 47 def from_short_name(short_name) all.find { |t| t.short_name == short_name } end |
Instance Method Details
#class_name ⇒ String
Returns name for specialized class for this type e.g. for reader, write or builder
77 78 79 |
# File 'src/lib/y2network/interface_type.rb', line 77 def class_name name.capitalize end |
#file_name ⇒ String
Returns name for file without suffix for this type e.g. for reader, write or builder
83 84 85 |
# File 'src/lib/y2network/interface_type.rb', line 83 def file_name name.downcase end |
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
87 88 89 90 91 92 93 94 95 |
# File 'src/lib/y2network/interface_type.rb', line 87 def respond_to_missing?(method_name, _include_private = false) return false unless method_name.to_s.end_with?("?") target_name = method_name.to_s[0..-2] InterfaceType.all.any? do |type| type.name.downcase == target_name || type.short_name == target_name end end |
#to_human_string ⇒ String
Returns the translated name
71 72 73 |
# File 'src/lib/y2network/interface_type.rb', line 71 def to_human_string _(name) end |