Class: Vedeu::Borders::DSL

Inherits:
Object
  • Object
show all
Includes:
DSL, DSL::Border, DSL::Presentation, DSL::Use
Defined in:
lib/vedeu/borders/dsl.rb

Overview

Provides a mechanism to help configure borders in Vedeu.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vedeu::DSL

Instance Attribute Details

#clientObject (readonly, protected) Originally defined in module DSL

Returns The object instance where the DSL is being used.

Returns:

  • (Object)

    The object instance where the DSL is being used.

#modelvoid (readonly, protected) Originally defined in module DSL

This method returns an undefined value.

Returns The new model object which the DSL is constructing.

Class Method Details

.border(name, &block) ⇒ Vedeu::Borders::Border

Parameters:

  • name (String|Symbol)

    The name of the interface or view to which this border belongs.

  • block (Proc)

Returns:

Raises:



23
24
25
26
27
28
# File 'lib/vedeu/borders/dsl.rb', line 23

def self.border(name, &block)
  fail Vedeu::Error::MissingRequired unless name
  fail Vedeu::Error::RequiresBlock unless block_given?

  Vedeu::Borders::Border.build(enabled: true, name: name, &block).store
end

Instance Method Details

#attributesHash<Symbol => void> (private) Originally defined in module DSL

Note:

Specific DSL classes may be overriding this method.

Returns the default attributes for the new model.

Returns:

  • (Hash<Symbol => void>)

#attrs(value, options) ⇒ Hash<Symbol => void> (private)

Returns:

  • (Hash<Symbol => void>)


317
318
319
# File 'lib/vedeu/borders/dsl.rb', line 317

def attrs(value, options)
  default_options.merge!(value: value).merge!(options)
end

#background(value = '') ⇒ String Also known as: bg, bgcolor, background=, bg=, bgcolor= Originally defined in module DSL::Presentation

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)

#bottom(value) ⇒ Boolean Also known as: show_bottom, bottom=

and false.

Parameters:

  • value (Boolean)

    All values evaluate as true except nil

Returns:



129
130
131
132
133
# File 'lib/vedeu/borders/dsl.rb', line 129

def bottom(value)
  boolean = value ? true : false

  model.show_bottom = boolean
end

#bottom_horizontal(char, options = {}) ⇒ String Also known as: bottom_horizontal=

Parameters:

  • char (String)

    Character to be used as the bottom horizontal border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


106
107
108
109
# File 'lib/vedeu/borders/dsl.rb', line 106

def bottom_horizontal(char, options = {})
  model.bottom_horizontal = Vedeu::Cells::BottomHorizontal
                            .new(attrs(char, options))
end

#bottom_left(char, options = {}) ⇒ String Also known as: bottom_left=

Parameters:

  • char (String)

    Character to be used as the bottom left border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


38
39
40
# File 'lib/vedeu/borders/dsl.rb', line 38

def bottom_left(char, options = {})
  model.bottom_left = Vedeu::Cells::BottomLeft.new(attrs(char, options))
end

#bottom_right(char, options = {}) ⇒ String Also known as: bottom_right=

Parameters:

  • char (String)

    Character to be used as the bottom right border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


51
52
53
# File 'lib/vedeu/borders/dsl.rb', line 51

def bottom_right(char, options = {})
  model.bottom_right = Vedeu::Cells::BottomRight.new(attrs(char, options))
end

#caption(value) ⇒ String Also known as: caption=

Parameters:

  • value (String)

    The caption.

Returns:

  • (String)


215
216
217
218
# File 'lib/vedeu/borders/dsl.rb', line 215

def caption(value)
  model.caption = value
  model.caption
end

#colour(attrs = {}) ⇒ Vedeu::Colours::Colour Also known as: colour= Originally defined in module DSL::Presentation

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:

#colour_attributesHash<Symbol => String> (private) Originally defined in module DSL::Presentation

Returns:

  • (Hash<Symbol => String>)

#default_optionsHash<Symbol => NilClass|String|Symbol> (private)

Returns:

  • (Hash<Symbol => NilClass|String|Symbol>)


322
323
324
325
326
327
328
329
# File 'lib/vedeu/borders/dsl.rb', line 322

def default_options
  {
    colour: model.colour,
    name:   model.name,
    style:  model.style,
    value:  nil,
  }
end

#disable!Boolean Also known as: disabled!

Returns:



58
59
60
61
62
63
64
65
66
67
# File 'lib/vedeu/borders/dsl.rb', line 58

def disable!
  model.enabled = false

  hide_bottom!
  hide_left!
  hide_right!
  hide_top!

  model.enabled
end

#enable!Boolean Also known as: enabled!

Returns:



72
73
74
75
76
77
78
79
80
81
# File 'lib/vedeu/borders/dsl.rb', line 72

def enable!
  model.enabled = true

  show_bottom!
  show_left!
  show_right!
  show_top!

  model.enabled
end

#foreground(value = '') ⇒ Object Also known as: fg, fgcolor, foreground=, fg=, fgcolor= Originally defined in module DSL::Presentation

See Also:

#hide_bottom!Object

Disable the bottom border.

See Also:



140
141
142
# File 'lib/vedeu/borders/dsl.rb', line 140

def hide_bottom!
  bottom(false)
end

#hide_left!Object

Disable the left border.

See Also:



166
167
168
# File 'lib/vedeu/borders/dsl.rb', line 166

def hide_left!
  left(false)
end

#hide_right!Object

Disable the right border.

See Also:



192
193
194
# File 'lib/vedeu/borders/dsl.rb', line 192

def hide_right!
  right(false)
end

#hide_top!Object

Disable the top border.

See Also:



236
237
238
# File 'lib/vedeu/borders/dsl.rb', line 236

def hide_top!
  top(false)
end

#horizontal(char, options = {}) ⇒ String Also known as: horizontal=

Parameters:

  • char (String)

    Character to be used as the horizontal border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


120
121
122
# File 'lib/vedeu/borders/dsl.rb', line 120

def horizontal(char, options = {})
  model.horizontal = Vedeu::Cells::Horizontal.new(attrs(char, options))
end

#initialize(model, client = nil) ⇒ void Originally defined in module DSL

Returns a new instance of the DSL class including Vedeu::DSL.

Parameters:

  • model (void)

    The model class which the DSL class is wrapping.

  • client (void) (defaults to: nil)

    The class where the DSL methods are being used.

#left(value) ⇒ Boolean Also known as: show_left, left=

Parameters:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:



155
156
157
158
159
# File 'lib/vedeu/borders/dsl.rb', line 155

def left(value)
  boolean = value ? true : false

  model.show_left = boolean
end

#left_vertical(char, options = {}) ⇒ String Also known as: left_vertical=

Parameters:

  • char (String)

    Character to be used as the left vertical border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


281
282
283
284
# File 'lib/vedeu/borders/dsl.rb', line 281

def left_vertical(char, options = {})
  model.left_vertical = Vedeu::Cells::LeftVertical
                        .new(attrs(char, options))
end

#nameNilClass|String|Symbol Originally defined in module DSL

Returns the model name if available.

Returns:

  • (NilClass|String|Symbol)

#right(value) ⇒ Boolean Also known as: show_right, right=

Parameters:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:



181
182
183
184
185
# File 'lib/vedeu/borders/dsl.rb', line 181

def right(value)
  boolean = value ? true : false

  model.show_right = boolean
end

#right_vertical(char, options = {}) ⇒ String Also known as: right_vertical=

Parameters:

  • char (String)

    Character to be used as the right vertical border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


295
296
297
298
# File 'lib/vedeu/borders/dsl.rb', line 295

def right_vertical(char, options = {})
  model.right_vertical = Vedeu::Cells::RightVertical
                         .new(attrs(char, options))
end

#show_bottom!Object

Enable the bottom border.

See Also:



147
148
149
# File 'lib/vedeu/borders/dsl.rb', line 147

def show_bottom!
  bottom(true)
end

#show_left!Object

Enable the left border.

See Also:



173
174
175
# File 'lib/vedeu/borders/dsl.rb', line 173

def show_left!
  left(true)
end

#show_right!Object

Enable the right border.

See Also:



199
200
201
# File 'lib/vedeu/borders/dsl.rb', line 199

def show_right!
  right(true)
end

#show_top!Object

Enable the top border.

See Also:



243
244
245
# File 'lib/vedeu/borders/dsl.rb', line 243

def show_top!
  top(true)
end

#style(value) ⇒ Vedeu::Presentation::Style Also known as: style=, styles, styles= Originally defined in module DSL::Presentation

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:

#title(value) ⇒ String Also known as: title=

Parameters:

  • value (String)

    The title.

Returns:

  • (String)


206
207
208
209
# File 'lib/vedeu/borders/dsl.rb', line 206

def title(value)
  model.title = value
  model.title
end

#top(value) ⇒ Boolean Also known as: show_top, top=

Parameters:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:



225
226
227
228
229
# File 'lib/vedeu/borders/dsl.rb', line 225

def top(value)
  boolean = value ? true : false

  model.show_top = boolean
end

#top_horizontal(char, options = {}) ⇒ String Also known as: top_horizontal=

Parameters:

  • char (String)

    Character to be used as the top horizontal border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


92
93
94
95
# File 'lib/vedeu/borders/dsl.rb', line 92

def top_horizontal(char, options = {})
  model.top_horizontal = Vedeu::Cells::TopHorizontal
                         .new(attrs(char, options))
end

#top_left(char, options = {}) ⇒ String Also known as: top_left=

Parameters:

  • char (String)

    Character to be used as the top left border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


255
256
257
# File 'lib/vedeu/borders/dsl.rb', line 255

def top_left(char, options = {})
  model.top_left = Vedeu::Cells::TopLeft.new(attrs(char, options))
end

#top_right(char, options = {}) ⇒ String Also known as: top_right=

Parameters:

  • char (String)

    Character to be used as the top right border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


268
269
270
# File 'lib/vedeu/borders/dsl.rb', line 268

def top_right(char, options = {})
  model.top_right = Vedeu::Cells::TopRight.new(attrs(char, options))
end

#use(name) ⇒ void Originally defined in module DSL::Use

Note:
  • Only models of the same repository can be used in this way.

  • If the stored model cannot be found, a ModelNotFound exception may be raised, or the request for an attribute may raise a NoMethodError exception.

This method returns an undefined value.

Use the attribute of stored model.

This DSL method provides access to a stored model by name. You can then request an attribute of that model for use within the current model. The models which current support this are Border, Geometry and Interface.

Examples:

# Here the character used for :my_border is used in
# :my_other_border.
Vedeu.border :my_other_border do
  top_right use(:my_border).top_right
end

Parameters:

  • name (String|Symbol)

    The name of the model with the value you wish to use.

Raises:

  • Vedeu::Error::ModelNotFound|Vedeu::Error::NoMethodError

    The model or attribute cannot be found.

#vertical(char, options = {}) ⇒ String Also known as: vertical=

Parameters:

  • char (String)

    Character to be used as the vertical border character.

  • options (Hash<Symbol => Hash<Symbol => String>|String| Symbol]) (defaults to: {})

    ptions [Hash<Symbol => Hash<Symbol => String>|String| Symbol]

Options Hash (options):

  • colour (Hash<Symbol => String>)
  • style (String|Symbol)

Returns:

  • (String)


309
310
311
# File 'lib/vedeu/borders/dsl.rb', line 309

def vertical(char, options = {})
  model.vertical = Vedeu::Cells::Vertical.new(attrs(char, options))
end