Sha256: ce3b5b8df1fad072fd945127c8b32e20898b08ae78b16649f6669ffb796b9b7f

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

module Vedeu

  module Presentation

    module Colour

      # Provides the foreground colour when included in a class with
      # a colour attribute.
      #
      # @api private
      #
      module Foreground

        include Vedeu::Repositories::Parent

        # When the foreground colour for the model exists, return it,
        # otherwise returns the parent foreground colour, or an empty
        # Vedeu::Colours::Foreground.
        #
        # @return [Vedeu::Colours::Foreground]
        def foreground
          @foreground ||= if colour && present?(colour.foreground)
                            colour.foreground

                          elsif self.is_a?(Vedeu::Views::Char) && name
                            interface.colour.foreground

                          elsif parent && present?(parent.foreground)
                            parent.foreground

                          else
                            Vedeu::Colours::Foreground.new

                          end
        end

        # Allows the setting of the foreground colour by coercing the
        # given value into a Vedeu::Colours::Foreground colour.
        #
        # @return [Vedeu::Colours::Foreground]
        def foreground=(value)
          @foreground = colour.foreground = value
          @_colour = @colour = colour
        end

      end # Foreground

    end # Colour

  end # Presentation

end # Vedeu

Version data entries

7 entries across 7 versions & 1 rubygems

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