class WaxTasks::Record
Attributes
hash[R]
pid[R]
Public Class Methods
new(hash)
click to toggle source
# File lib/wax_tasks/record.rb, line 8 def initialize(hash) @hash = hash @pid = @hash.dig 'pid' end
Public Instance Methods
keep_only(fields)
click to toggle source
# File lib/wax_tasks/record.rb, line 53 def keep_only(fields) @hash.select! { |k, _v| fields.include? k } end
keys()
click to toggle source
# File lib/wax_tasks/record.rb, line 25 def keys @hash.keys end
lunr_normalize_values()
click to toggle source
# File lib/wax_tasks/record.rb, line 19 def lunr_normalize_values @hash.transform_values { |v| Utils.lunr_normalize v } end
order()
click to toggle source
# File lib/wax_tasks/record.rb, line 13 def order @hash.dig 'order' end
order?()
click to toggle source
# File lib/wax_tasks/record.rb, line 47 def order? !order.to_s.empty? end
permalink?()
click to toggle source
# File lib/wax_tasks/record.rb, line 41 def permalink? @hash.key? 'permalink' end
set(key, value)
click to toggle source
- PATCH
-
rename 'fullwidth' to 'full' to
(1) avoid breaking wax_iiif with special 'full' variant label (2) avoid breaking wax_theme which still expects 'full' to provide an image path this can be deprecated when a new version of wax_theme looks for another fullsize key
# File lib/wax_tasks/record.rb, line 34 def set(key, value) key = 'full' if key == 'fullwidth' @hash[key] = value end
write_to_page(dir)
click to toggle source
# File lib/wax_tasks/record.rb, line 59 def write_to_page(dir) raise Error::MissingPid if @pid.nil? path = "#{dir}/#{Utils.slug(@pid)}.md" if File.exist? path 0 else FileUtils.mkdir_p File.dirname(path) File.open(path, 'w') { |f| f.puts "#{@hash.to_yaml}---" } 1 end end