Class: Proforma::Modeling::Banner
- Inherits:
-
Object
- Object
- Proforma::Modeling::Banner
- Includes:
- Compiling::Compilable
- Defined in:
- lib/proforma/modeling/banner.rb
Overview
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.
Instance Attribute Summary collapse
- #details ⇒ Object
-
#image ⇒ Object
Returns the value of attribute image.
- #image_height ⇒ Object
- #image_width ⇒ Object
- #title ⇒ Object
Instance Method Summary collapse
- #compile(data, evaluator) ⇒ Object
-
#initialize(details: '', image: nil, image_height: nil, image_width: nil, title: '') ⇒ Banner
constructor
A new instance of Banner.
Constructor Details
#initialize(details: '', image: nil, image_height: nil, image_width: nil, title: '') ⇒ Banner
Returns a new instance of Banner.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/proforma/modeling/banner.rb', line 23 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 |
Instance Attribute Details
#details ⇒ Object
37 38 39 |
# File 'lib/proforma/modeling/banner.rb', line 37 def details @details.to_s end |
#image ⇒ Object
Returns the value of attribute image.
21 22 23 |
# File 'lib/proforma/modeling/banner.rb', line 21 def image @image end |
#image_height ⇒ Object
45 46 47 |
# File 'lib/proforma/modeling/banner.rb', line 45 def image_height @image_height ? @image_height.to_f : nil end |
#image_width ⇒ Object
49 50 51 |
# File 'lib/proforma/modeling/banner.rb', line 49 def image_width @image_width ? @image_width.to_f : nil end |
#title ⇒ Object
41 42 43 |
# File 'lib/proforma/modeling/banner.rb', line 41 def title @title.to_s end |
Instance Method Details
#compile(data, evaluator) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/proforma/modeling/banner.rb', line 53 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 |