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

Attributes included from DSL

#client, #model

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL::Use

#use

Methods included from DSL::Presentation

#background, #colour, #colour_attributes, #foreground, #no_wordwrap!, #style, #wordwrap

Methods included from DSL::Border

included

Methods included from DSL

#attributes, #initialize, #method_missing, #name

Dynamic Method Handling

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

Class Method Details

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

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

  • block (Proc)

Returns:

Raises:



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

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

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

Instance Method Details

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

Returns:

  • (Hash<Symbol => void>)


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

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

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

and false.

Parameters:

  • value (Boolean)

    All values evaluate as true except nil

Returns:



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

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)


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

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)


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

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)


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

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)


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

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

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

Returns:

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


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

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

#disable!Boolean Also known as: disabled!

Returns:



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

def disable!
  model.enabled = false

  hide_bottom!
  hide_left!
  hide_right!
  hide_top!

  model.enabled
end

#enable!Boolean Also known as: enabled!

Returns:



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

def enable!
  model.enabled = true

  show_bottom!
  show_left!
  show_right!
  show_top!

  model.enabled
end

#hide_bottom!Object

Disable the bottom border.

See Also:



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

def hide_bottom!
  bottom(false)
end

#hide_left!Object

Disable the left border.

See Also:



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

def hide_left!
  left(false)
end

#hide_right!Object

Disable the right border.

See Also:



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

def hide_right!
  right(false)
end

#hide_top!Object

Disable the top border.

See Also:



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

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)


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

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

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

Parameters:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:



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

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)


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

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

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

Parameters:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:



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

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)


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

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:



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

def show_bottom!
  bottom(true)
end

#show_left!Object

Enable the left border.

See Also:



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

def show_left!
  left(true)
end

#show_right!Object

Enable the right border.

See Also:



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

def show_right!
  right(true)
end

#show_top!Object

Enable the top border.

See Also:



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

def show_top!
  top(true)
end

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

Parameters:

  • value (String)

    The title.

Returns:

  • (String)


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

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:



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

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)


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

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)


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

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)


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

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

#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)


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

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