Class: Slapp::Parser
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#slackware_version ⇒ Object
Returns the value of attribute slackware_version.
Instance Method Summary collapse
-
#initialize(path, slackware_version) ⇒ Parser
constructor
A new instance of Parser.
- #packages ⇒ Object
- #total_size_compressed ⇒ Object
- #total_size_uncompressed ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(path, slackware_version) ⇒ Parser
Returns a new instance of Parser.
6 7 8 9 10 |
# File 'lib/slapp/parser.rb', line 6 def initialize(path, slackware_version) @lines = File.readlines(path, :encoding => 'ISO-8859-1') @contents = @lines.join('') @slackware_version = slackware_version end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
4 5 6 |
# File 'lib/slapp/parser.rb', line 4 def contents @contents end |
#lines ⇒ Object
Returns the value of attribute lines.
4 5 6 |
# File 'lib/slapp/parser.rb', line 4 def lines @lines end |
#slackware_version ⇒ Object
Returns the value of attribute slackware_version.
4 5 6 |
# File 'lib/slapp/parser.rb', line 4 def slackware_version @slackware_version end |
Instance Method Details
#packages ⇒ Object
24 25 26 27 28 |
# File 'lib/slapp/parser.rb', line 24 def packages raw_packages.map { |pkg| Slapp::Package.new pkg.first, slackware_version } end |
#total_size_compressed ⇒ Object
18 19 20 21 22 |
# File 'lib/slapp/parser.rb', line 18 def total_size_compressed line = lines.select { |line| line =~ total_size_regex('compressed') } match = total_size_regex('compressed').match(line.first) convert_to_bytes match[1] end |
#total_size_uncompressed ⇒ Object
12 13 14 15 16 |
# File 'lib/slapp/parser.rb', line 12 def total_size_uncompressed line = lines.select { |line| line =~ total_size_regex('uncompressed') } match = total_size_regex('uncompressed').match(line.first) convert_to_bytes match[1] end |