class Estatic::Resource
Attributes
locals[RW]
name[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/estatic/resource.rb, line 5 def initialize(name) @name = name @locals = get_locals end
Public Instance Methods
directory()
click to toggle source
# File lib/estatic/resource.rb, line 23 def directory File.join(Estatic.configuration.estatic_site_path, name) end
get_locals()
click to toggle source
# File lib/estatic/resource.rb, line 10 def get_locals locals = Estatic.configuration.locals.detect { |e| e.keys.first == name }&.values&.first || [] locals.map { |local| [local.keys.first, local.values.first] }.to_h end
products_in_chunks()
click to toggle source
# File lib/estatic/resource.rb, line 15 def products_in_chunks @chunks ||= products.each_slice(Estatic.configuration.chunk).to_a end
proper_name()
click to toggle source
# File lib/estatic/resource.rb, line 27 def proper_name name.gsub('-', ' ').split.map(&:capitalize).join(' ') end
total_chunks()
click to toggle source
# File lib/estatic/resource.rb, line 19 def total_chunks products_in_chunks.size end
Private Instance Methods
product(attributes)
click to toggle source
# File lib/estatic/resource.rb, line 33 def product(attributes) product = attributes.map do |key, value| if key.start_with? 'json_' [key.sub('json_', ''), JSON.parse(value)] else [key, value] end end product.to_h end