Class: Kanrisuru::Core::Yum::Parser::Search

Inherits:
Base
  • Object
show all
Defined in:
lib/kanrisuru/core/yum/parsers/search.rb

Class Method Summary collapse

Methods inherited from Base

extract_single_yum_line, parse_yum_line

Class Method Details

.parse(command) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kanrisuru/core/yum/parsers/search.rb', line 8

def self.parse(command)
  lines = command.to_a
  result = []

  lines.each do |line|
    line = line.gsub(/\s{2}/, '')
    values = line.split(' : ')
    next if values.length != 2

    full_name = values[0]
    name, architecture = full_name.split('.')
    summary = values[1]

    result << Kanrisuru::Core::Yum::PackageSearchResult.new(name, architecture, summary)
  end

  result
end