Class: Sfdown::Parser
- Inherits:
-
Object
- Object
- Sfdown::Parser
- Defined in:
- lib/sfdown.rb
Overview
Turns a directory page's HTML into child Nodes, merging table rows with the net.sf.files JS object.
Constant Summary collapse
- UNITS =
{ "b" => 1, "kb" => 1024, "mb" => 1024**2, "gb" => 1024**3, "tb" => 1024**4 }.freeze
Instance Method Summary collapse
-
#initialize(project) ⇒ Parser
constructor
A new instance of Parser.
-
#parse(html, parent_path = "") ⇒ Object
Parse HTML into child Nodes.
Constructor Details
#initialize(project) ⇒ Parser
Returns a new instance of Parser.
176 177 178 |
# File 'lib/sfdown.rb', line 176 def initialize(project) @project = project end |
Instance Method Details
#parse(html, parent_path = "") ⇒ Object
Parse HTML into child Nodes. parent_path is the directory's full path ("" = root).
181 182 183 184 185 |
# File 'lib/sfdown.rb', line 181 def parse(html, parent_path = "") doc = Nokogiri::HTML(html) = (html) doc.css("table#files_list > tbody > tr").filter_map { |row| node_from_row(row, parent_path, ) } end |