Sha256: 44cdbbbeca923969f2e150c2e2b5b9a85de8ecd4549bc238d9b24159f5d91945
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true # # Copyright (c) 2019-present, Blue Marble Payroll, LLC # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # module Proforma module Modeling # A Banner is a specific type of header that is comprised of an image and some text. # Both the image and text could be optional and, like all modeling components, # it is up to the rendering engine how to render it. class Banner include Compiling::Compilable acts_as_hashable attr_writer :details, :image_height, :image_width, :title attr_accessor :image def initialize( details: '', image: nil, image_height: nil, image_width: nil, title: '' ) @details = details @image = image @image_height = image_height @image_width = image_width @title = title end def details @details.to_s end def title @title.to_s end def image_height @image_height ? @image_height.to_f : nil end def image_width @image_width ? @image_width.to_f : nil end def compile(data, evaluator) resolved_image = image.to_s.empty? ? nil : evaluator.value(data, image) self.class.new( details: evaluator.text(data, details), image: resolved_image, image_height: image_height, image_width: image_width, title: evaluator.text(data, title) ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
proforma-1.0.2 | lib/proforma/modeling/banner.rb |
proforma-1.0.1 | lib/proforma/modeling/banner.rb |