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")
- UNKNOWN =
Unknown interfaces
new(N_("Unknown"), "unknown")
- SUPPORTED_COMMON =
[ETHERNET, VLAN, BRIDGE, TUN, TAP, BONDING].freeze
- SUPPORTED_S390 =
[HSI, CTC, FICON, QETH, LCS].freeze
- UNSUPPORTED_S390 =
[DUMMY, WIRELESS, INFINIBAND].freeze
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.
-
.supported ⇒ Array<InterfaceType>
Returns all the supported interfaces for the current architecture.
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
71 72 73 74 75 |
# File 'src/lib/y2network/interface_type.rb', line 71 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
105 106 107 108 109 110 111 112 |
# File 'src/lib/y2network/interface_type.rb', line 105 def method_missing(method_name, *arguments, &block) return super unless respond_to_missing?(method_name) raise ArgumentError, "no params are accepted for method #{method_name}" if !arguments.empty? 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
62 63 64 |
# File 'src/lib/y2network/interface_type.rb', line 62 def name @name end |
#short_name ⇒ String (readonly)
Returns type's short name
64 65 66 |
# File 'src/lib/y2network/interface_type.rb', line 64 def short_name @short_name end |
Class Method Details
.all ⇒ Array<InterfaceType>
Returns all the existing types
39 40 41 42 43 |
# File 'src/lib/y2network/interface_type.rb', line 39 def all @all ||= 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
56 57 58 |
# File 'src/lib/y2network/interface_type.rb', line 56 def from_short_name(short_name) all.find { |t| t.short_name == short_name } end |
.supported ⇒ Array<InterfaceType>
Returns all the supported interfaces for the current architecture
48 49 50 |
# File 'src/lib/y2network/interface_type.rb', line 48 def supported SUPPORTED_COMMON + (Yast::Arch.s390 ? SUPPORTED_S390 : UNSUPPORTED_S390) end |
Instance Method Details
#class_name ⇒ String
Returns name for specialized class for this type e.g. for reader, write or builder
86 87 88 |
# File 'src/lib/y2network/interface_type.rb', line 86 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
92 93 94 |
# File 'src/lib/y2network/interface_type.rb', line 92 def file_name name.downcase end |
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
96 97 98 99 100 101 102 103 |
# File 'src/lib/y2network/interface_type.rb', line 96 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, type.short_name].include?(target_name) end end |
#to_human_string ⇒ String
Returns the translated name
80 81 82 |
# File 'src/lib/y2network/interface_type.rb', line 80 def to_human_string _(name) end |