Sha256: de7532804a3eda132c2ea8dd7e32012f2e844e369271327ca7c574c5378a5c52

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

require 'vedeu/geometries/positionable'

module Vedeu

  module Presentation

    include Vedeu::Geometries::Positionable
    include Vedeu::Presentation::Colour
    include Vedeu::Presentation::Styles

    # Converts the colours and styles to escape sequences, and when
    # the parent model has previously set the colour and style,
    # reverts back to that for consistent formatting.
    #
    # @return [String] An escape sequence with value interpolated.
    def to_s
      render_position { render_colour { render_style { value } } }
    end
    alias_method :to_str, :to_s

    private

    # Renders the colour attributes of the receiver and yields (to
    # then render the styles).
    #
    # @return [String]
    def render_colour
      "#{colour}#{yield}".freeze
    end

    # @return [String]
    def render_position
      return position.to_s { yield } if position?

      yield
    end

    # Renders the style attributes of the receiver and yields (to
    # then render the next model, or finally, the content).
    #
    # @return [String]
    def render_style
      "#{style}#{yield}".freeze
    end

  end # Presentation

end # Vedeu

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.7.3 lib/vedeu/presentation/presentation.rb
vedeu-0.7.2 lib/vedeu/presentation/presentation.rb
vedeu-0.7.1 lib/vedeu/presentation/presentation.rb
vedeu-0.7.0 lib/vedeu/presentation/presentation.rb
vedeu-0.6.71 lib/vedeu/presentation/presentation.rb