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:



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

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


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

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:



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

def bottom(value)
  model.show_bottom = Vedeu::Boolean.coerce(value)
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)


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

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)


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

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)


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

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)


210
211
212
213
# File 'lib/vedeu/borders/dsl.rb', line 210

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

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

Returns:

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


315
316
317
318
319
320
321
322
# File 'lib/vedeu/borders/dsl.rb', line 315

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

#disable!Boolean Also known as: disabled!

Returns:



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

def disable!
  model.enabled = false

  hide_bottom!
  hide_left!
  hide_right!
  hide_top!

  model.enabled
end

#enable!Boolean Also known as: enabled!

Returns:



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

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:



163
164
165
# File 'lib/vedeu/borders/dsl.rb', line 163

def hide_left!
  left(false)
end

#hide_right!Object

Disable the right border.

See Also:



187
188
189
# File 'lib/vedeu/borders/dsl.rb', line 187

def hide_right!
  right(false)
end

#hide_top!Object

Disable the top border.

See Also:



229
230
231
# File 'lib/vedeu/borders/dsl.rb', line 229

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)


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

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
# File 'lib/vedeu/borders/dsl.rb', line 154

def left(value)
  model.show_left = Vedeu::Boolean.coerce(value)
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)


274
275
276
277
# File 'lib/vedeu/borders/dsl.rb', line 274

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:



178
179
180
# File 'lib/vedeu/borders/dsl.rb', line 178

def right(value)
  model.show_right = Vedeu::Boolean.coerce(value)
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)


288
289
290
291
# File 'lib/vedeu/borders/dsl.rb', line 288

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:



170
171
172
# File 'lib/vedeu/borders/dsl.rb', line 170

def show_left!
  left(true)
end

#show_right!Object

Enable the right border.

See Also:



194
195
196
# File 'lib/vedeu/borders/dsl.rb', line 194

def show_right!
  right(true)
end

#show_top!Object

Enable the top border.

See Also:



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

def show_top!
  top(true)
end

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

Parameters:

  • value (String)

    The title.

Returns:

  • (String)


201
202
203
204
# File 'lib/vedeu/borders/dsl.rb', line 201

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:



220
221
222
# File 'lib/vedeu/borders/dsl.rb', line 220

def top(value)
  model.show_top = Vedeu::Boolean.coerce(value)
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)


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

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)


248
249
250
# File 'lib/vedeu/borders/dsl.rb', line 248

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)


261
262
263
# File 'lib/vedeu/borders/dsl.rb', line 261

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)


302
303
304
# File 'lib/vedeu/borders/dsl.rb', line 302

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