Skip to content

Commit

Permalink
Improve InterfacesCollection#by_type approach
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 27, 2021
1 parent 30b77e3 commit 49dd09d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/y2network/interfaces_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def by_busid(busid)
# @param type [InterfaceType,String,Symbol] device type or its short name
# @return [InterfacesCollection] list of found interfaces
def by_type(type)
short_name = type.is_a?(Y2Network::InterfaceType) ? type.short_name : type.to_s
InterfacesCollection.new(interfaces.select { |i| i.type.short_name == short_name })
type = InterfaceType.from_short_name(type.to_s) unless type.is_a?(InterfaceType)
InterfacesCollection.new(interfaces.select { |i| i.type == type })
end

# Returns the list of physical interfaces
Expand Down

0 comments on commit 49dd09d

Please sign in to comment.