Class: Hx::Sort
Instance Method Summary collapse
- #each_entry(selector) ⇒ Object
- #edit_entry(path, prototype = nil) ⇒ Object
- #get_entry(path) ⇒ Object
-
#initialize(input, options) ⇒ Sort
constructor
A new instance of Sort.
Methods included from Filter
Constructor Details
Instance Method Details
#each_entry(selector) ⇒ Object
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/hx.rb', line 313 def each_entry(selector) entries = [] @input.each_entry(selector) do |path, entry| entries << [path, entry] end unless @key_fields.empty? entries = entries.sort_by do |path, entry| @key_fields.map { |f| entry[f] } end end entries.reverse! if @reverse entries.each do |path, entry| yield path, entry end self end |
#edit_entry(path, prototype = nil) ⇒ Object
308 309 310 311 |
# File 'lib/hx.rb', line 308 def edit_entry(path, prototype=nil) @input.edit_entry(path, prototype) { |text| yield text } self end |
#get_entry(path) ⇒ Object
330 331 332 |
# File 'lib/hx.rb', line 330 def get_entry(path) @input.get_entry(path) end |