Sha256: 45cc8a02a9f686355312f3315d68e0ae0bebd3ec4abe56c91679abe89127051e
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
module Vedeu # This module allows the sharing of presentation concerns between the models: # Interface, Line and Stream. # # @api private module Presentation # Returns the colour attributes of the receiving class. # # @return [Hash] def view_attributes { colour: attributes[:colour], style: attributes[:style], } end # Returns a new Colour instance. # # @return [Colour] def colour @colour ||= Colour.new(attributes[:colour]) end # Returns a new Style instance. # # @return [Style] def style @style ||= Style.new(attributes[:style]) end # Converts the colours and styles to escape sequences, and if the parent # model has previously set the colour and style, reverts back to that for # consistent formatting. # # @return [String] def to_s render_colour do render_style do data end end end private # @api private # @return [String] def render_colour(&block) [ colour.to_s, yield, parent_colour ].join end # @api private # @return [String] def render_style(&block) [ style.to_s, yield, parent_style ].join end # @api private # @return [String] def parent_colour return '' if parent.nil? Colour.new(parent[:colour]).to_s end # @api private # @return [String] def parent_style return '' if parent.nil? Style.new(parent[:style]).to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.2.0 | lib/vedeu/models/attributes/presentation.rb |
vedeu-0.1.19 | lib/vedeu/models/attributes/presentation.rb |