Module: Vedeu::Presentation::Colour Private

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Provides colour related presentation behaviour.

Instance Method Summary collapse

Methods included from Parent

#name, #parent, #parent?

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Instance Method Details

#backgroundVedeu::Colours::Background

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vedeu/presentation/colour.rb', line 20

def background
  @background ||= if colour && present?(colour.background)
                    colour.background

                  elsif named_colour?
                    named_colour.background

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

                  else
                    Vedeu::Colours::Background.new

                  end
end

#background=(value) ⇒ Vedeu::Colours::Background

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.



40
41
42
43
# File 'lib/vedeu/presentation/colour.rb', line 40

def background=(value)
  @background = colour.background = value
  @_colour = @colour = colour
end

#colourVedeu::Colours::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vedeu/presentation/colour.rb', line 46

def colour
  @_colour ||= if colour?
                 Vedeu::Colours::Colour.coerce(@colour)

               elsif parent_colour?
                 Vedeu::Colours::Colour.coerce(parent_colour)

               elsif named_colour?
                 Vedeu::Colours::Colour.coerce(named_colour)

               else
                 Vedeu::Colours::Colour.new

               end
end

#colour=(value) ⇒ Vedeu::Colours::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.



66
67
68
# File 'lib/vedeu/presentation/colour.rb', line 66

def colour=(value)
  @_colour = @colour = Vedeu::Colours::Colour.coerce(value)
end

#colour?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



71
72
73
# File 'lib/vedeu/presentation/colour.rb', line 71

def colour?
  present?(@colour)
end

#foregroundVedeu::Colours::Foreground

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/vedeu/presentation/colour.rb', line 80

def foreground
  @foreground ||= if colour && present?(colour.foreground)
                    colour.foreground

                  elsif named_colour?
                    named_colour.foreground

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

                  else
                    Vedeu::Colours::Foreground.new

                  end
end

#foreground=(value) ⇒ Vedeu::Colours::Foreground

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.



100
101
102
103
# File 'lib/vedeu/presentation/colour.rb', line 100

def foreground=(value)
  @foreground = colour.foreground = value
  @_colour = @colour = colour
end

#interfaceVedeu::Interfaces::Interface (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the named interface/view from the interfaces repository.



108
109
110
# File 'lib/vedeu/presentation/colour.rb', line 108

def interface
  Vedeu.interfaces.by_name(name)
end

#named_colourVedeu::Colours::Colour (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



113
114
115
# File 'lib/vedeu/presentation/colour.rb', line 113

def named_colour
  interface.colour
end

#named_colour?Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



118
119
120
121
122
# File 'lib/vedeu/presentation/colour.rb', line 118

def named_colour?
  return false if is_a?(Vedeu::Interfaces::Interface)

  present?(name) && Vedeu.interfaces.registered?(name)
end

#parent_colourVedeu::Colours::Colour (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



125
126
127
# File 'lib/vedeu/presentation/colour.rb', line 125

def parent_colour
  parent.colour
end

#parent_colour?Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



130
131
132
# File 'lib/vedeu/presentation/colour.rb', line 130

def parent_colour?
  parent? && parent.respond_to?(:colour?)
end

#render_colour(&block) ⇒ String (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders the colour attributes of the receiver and yields (to then render the styles).

Parameters:

  • block (Proc)

Returns:

  • (String)


139
140
141
# File 'lib/vedeu/presentation/colour.rb', line 139

def render_colour(&block)
  "#{colour}#{yield}"
end