Module: Vedeu::API::Helpers

Included in:
Interface, Line, Stream
Defined in:
lib/vedeu/api/helpers.rb

Instance Method Summary collapse

Instance Method Details

#colour(values = {}) ⇒ Object

Define either or both foreground and background colours for an interface, line or a stream.

Examples:

interface 'my_interface' do
  colour background: '#000000', foreground: '#ffffff'
  ... some interface attributes ...

line do
  colour background: '#000000', foreground: '#ffffff'
  ... some line attributes ...

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

Parameters:

  • values (Hash) (defaults to: {})

Returns:



25
26
27
28
29
30
# File 'lib/vedeu/api/helpers.rb', line 25

def colour(values = {})
  fail InvalidArgument, '#colour expects a Hash containing :foreground,' \
                        ' :background or both.' unless values.is_a?(Hash)

  attributes[:colour] = values
end

#style(values = [], &block) ⇒ Object

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

Examples:

interface 'my_interface' do
  style 'normal'
  ... some interface attributes ...
end

line do
  style ['bold', 'underline']
  ... some line attributes ...

stream do
  style 'blink'
  ... some stream attributes ...

Parameters:

  • values (Array|String) (defaults to: [])
  • block (Proc)

Returns:



53
54
55
56
57
58
59
60
61
# File 'lib/vedeu/api/helpers.rb', line 53

def style(values = [], &block)
  if block_given?
    attributes[:streams] << API::Stream.build({ style: [values] }, &block)

  else
    [values].flatten.each { |value| attributes[:style] << value }

  end
end