Module: Vedeu::Presentation::Colour

Included in:
Vedeu::Presentation
Defined in:
lib/vedeu/output/presentation/colour.rb

Overview

Provides colour related presentation behaviour.

Instance Method Summary collapse

Instance Method Details

#backgroundVedeu::Colours::Background

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



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vedeu/output/presentation/colour.rb', line 14

def background
  @background ||= if colour
                    colour.background

                  elsif parent
                    parent.background

                  else
                    Vedeu::Colours::Background.new

                  end
end

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

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



31
32
33
34
35
# File 'lib/vedeu/output/presentation/colour.rb', line 31

def background=(value)
  @colour = Vedeu::Colours::Colour.coerce(
    background: Vedeu::Colours::Background.coerce(value),
    foreground: colour.foreground)
end

#colourVedeu::Colours::Colour



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vedeu/output/presentation/colour.rb', line 38

def colour
  @colour ||= if attributes[:colour]
                Vedeu::Colours::Colour.coerce(attributes[:colour])

              elsif parent
                Vedeu::Colours::Colour.coerce(parent.colour)

              else
                Vedeu::Colours::Colour.new

              end
end

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

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



55
56
57
# File 'lib/vedeu/output/presentation/colour.rb', line 55

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

#foregroundVedeu::Colours::Foreground

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



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vedeu/output/presentation/colour.rb', line 64

def foreground
  @foreground ||= if colour
                    colour.foreground

                  elsif parent
                    parent.foreground

                  else
                    Vedeu::Colours::Foreground.new

                  end
end

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

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



81
82
83
84
85
# File 'lib/vedeu/output/presentation/colour.rb', line 81

def foreground=(value)
  @colour = Vedeu::Colours::Colour.coerce(
    background: colour.background,
    foreground: Vedeu::Colours::Foreground.coerce(value))
end