Module: Vedeu::DSL::Presentation

Included in:
Borders::DSL, Elements, Interfaces::DSL
Defined in:
lib/vedeu/dsl/presentation.rb

Overview

Provides colour and style helpers for use in the Interfaces::DSL, Line and Stream classes.

Instance Method Summary collapse

Instance Method Details

#background(value = '') ⇒ String Also known as: bg, bgcolor, background=, bg=, bgcolor=

Note:

The last defined background colour for a particular interface, line or stream overrides previously defined entries in the same block.

Define the background colour for an interface, line, or a stream. When called with a block, will create a new stream with the background colour specified. When the block terminates, the background will return to that of the parent.

Examples:

interface 'my_interface' do
  background '#0022ff' # /or/ (blue)
  bgcolor    '#22ff00' # /or/ (blue is overridden to green)
  bg         '#ff0022' #      (green is overridden to red)
  # ...

  lines do
    background '#2200ff'
    # ...

    stream do
      background '#22ff00'
      # ...
    end
  end
end

Parameters:

  • value (String) (defaults to: '')

    A HTML/CSS value.

Returns:

  • (String)


43
44
45
# File 'lib/vedeu/dsl/presentation.rb', line 43

def background(value = '')
  colour(background: Vedeu::Colours::Background.coerce(value))
end

#colour(attrs = {}) ⇒ Vedeu::Colours::Colour Also known as: colour=

Note:

Rejects invalid keys and empty/nil attributes. Also, the last defined colour for a particular interface, line or stream overrides previously defined entries in the same block.

Define either or both foreground and background colours for an interface, line or a stream. At least one attribute is required.

Examples:

interface 'my_interface' do
  colour background: '#ff00ff', foreground: '#ffff00'
  # ...

  lines do
    colour background: '#000000', foreground: '#ffffff'
    # ...

    stream do
      colour background: '#000000', foreground: '#ffffff'
      # ...
    end
  end
end

Parameters:

Returns:



91
92
93
94
# File 'lib/vedeu/dsl/presentation.rb', line 91

def colour(attrs = {})
  model.colour = Vedeu::Colours::Colour
                 .coerce(colour_attributes.merge!(attrs))
end

#colour_attributesHash<Symbol => String> (private)

Returns:

  • (Hash<Symbol => String>)


144
145
146
147
148
149
# File 'lib/vedeu/dsl/presentation.rb', line 144

def colour_attributes
  {
    background: model.colour.background,
    foreground: model.colour.foreground,
  }
end

#foreground(value = '') ⇒ Object Also known as: fg, fgcolor, foreground=, fg=, fgcolor=

See Also:



53
54
55
# File 'lib/vedeu/dsl/presentation.rb', line 53

def foreground(value = '')
  colour(foreground: Vedeu::Colours::Foreground.coerce(value))
end

#no_wordwrap!Boolean

Instruct the view to not use wordwrapping. (Default)

Returns:



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

def no_wordwrap!
  wordwrap(false)
end

#style(value) ⇒ Vedeu::Presentation::Style Also known as: style=, styles, styles=

Define a style or styles for an interface, line or a stream.

Examples:

interface 'my_interface' do
  style 'normal'
  # ...
end

lines do
  style ['bold', 'underline']
  # ...
end

stream do
  style 'blink'
  # ...
end

Parameters:

  • value (Array<Symbol>|Array<String>|Symbol|String)

Returns:



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

def style(value)
  model.style = Vedeu::Presentation::Style.coerce(value)
end

#wordwrap(value = true) ⇒ Boolean Also known as: wordwrap!

Specify whether the view should use wordwrapping (default).

Parameters:

  • value (Boolean) (defaults to: true)

Returns:



136
137
138
# File 'lib/vedeu/dsl/presentation.rb', line 136

def wordwrap(value = true)
  model.wordwrap = Vedeu::Boolean.coerce(value)
end