Class: Vedeu::DSL::Border

Inherits:
Object
  • Object
show all
Includes:
Vedeu::DSL, Colour, Style
Defined in:
lib/vedeu/dsl/components/border.rb

Overview

DSL for creating borders for interfaces.

Allows customisation for the border’s sides and corners; a custom foreground and background, style, and whether a particular side should be drawn or not.

Examples:

# Borders can be defined as part of a view definition...
Vedeu.renders do
  view 'border_demo' do
    border do
      # ...

# ...or standalone; referencing the target interface or view.
Vedeu.border 'some_interface' do
  # ...

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Style

#style

Methods included from Colour

#background, #colour, #foreground

Methods included from Vedeu::DSL

#method_missing

Constructor Details

#initialize(model, client = nil) ⇒ Vedeu::DSL::Border

Returns an instance of DSL::Border.

Parameters:

  • model (Border)
  • client (Object) (defaults to: nil)


53
54
55
56
# File 'lib/vedeu/dsl/components/border.rb', line 53

def initialize(model, client = nil)
  @model  = model
  @client = client
end

Dynamic Method Handling

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

Instance Attribute Details

#clientObject (readonly, private)

Returns:

  • (Object)


279
280
281
# File 'lib/vedeu/dsl/components/border.rb', line 279

def client
  @client
end

#modelBorder (readonly, private)

Returns:



282
283
284
# File 'lib/vedeu/dsl/components/border.rb', line 282

def model
  @model
end

Class Method Details

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

Specify the border of an interface or view with a simple DSL.

Examples:

Vedeu.border 'some_interface' do
  # ...

Parameters:

  • name (String)

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

  • block (Proc)

Returns:

Raises:

  • (InvalidSyntax)

    The required block was not given.



42
43
44
45
46
# File 'lib/vedeu/dsl/components/border.rb', line 42

def self.border(name, &block)
  fail InvalidSyntax, 'block not given' unless block_given?

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

Instance Method Details

#bottom(boolean) ⇒ Boolean Also known as: show_bottom

Enable/disable the bottom border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      bottom false
      # ... or
      hide_bottom!
      # ... or
      show_bottom!

Parameters:

  • boolean (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


123
124
125
# File 'lib/vedeu/dsl/components/border.rb', line 123

def bottom(boolean)
  model.show_bottom = !!boolean
end

#bottom_left(char) ⇒ String

Set the character to be used to draw the bottom left corner of the border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      bottom_left '+'
      # ...

Parameters:

  • char (String)

    Character to be used as the bottom left border character.

Returns:

  • (String)


71
72
73
# File 'lib/vedeu/dsl/components/border.rb', line 71

def bottom_left(char)
  model.bottom_left = char
end

#bottom_right(char) ⇒ String

Set the character to be used to draw the bottom right corner of the border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      bottom_right '+'
      # ...

Parameters:

  • char (String)

    Character to be used as the bottom right border character.

Returns:

  • (String)


88
89
90
# File 'lib/vedeu/dsl/components/border.rb', line 88

def bottom_right(char)
  model.bottom_right = char
end

#hide_bottom!Object

See Also:



129
130
131
# File 'lib/vedeu/dsl/components/border.rb', line 129

def hide_bottom!
  bottom(false)
end

#hide_left!Object

See Also:



159
160
161
# File 'lib/vedeu/dsl/components/border.rb', line 159

def hide_left!
  left(false)
end

#hide_right!Object

See Also:



189
190
191
# File 'lib/vedeu/dsl/components/border.rb', line 189

def hide_right!
  right(false)
end

#hide_top!Object

See Also:



219
220
221
# File 'lib/vedeu/dsl/components/border.rb', line 219

def hide_top!
  top(false)
end

#horizontal(char) ⇒ String

Set the character to be used to draw a horizontal part of the border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      horizontal '-'
      # ...

Parameters:

  • char (String)

    Character to be used as the horizontal border character.

Returns:

  • (String)


104
105
106
# File 'lib/vedeu/dsl/components/border.rb', line 104

def horizontal(char)
  model.horizontal = char
end

#left(boolean) ⇒ Boolean Also known as: show_left

Enable/disable the left border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      left false
      # ... or
      hide_left!
      # ... or
      show_left!

Parameters:

  • boolean (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


153
154
155
# File 'lib/vedeu/dsl/components/border.rb', line 153

def left(boolean)
  model.show_left = !!boolean
end

#right(boolean) ⇒ Boolean Also known as: show_right

Enable/disable the right border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      right false
      # ... or
      hide_right!
      # ... or
      show_right!

Parameters:

  • boolean (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


183
184
185
# File 'lib/vedeu/dsl/components/border.rb', line 183

def right(boolean)
  model.show_right = !!boolean
end

#show_bottom!Object

See Also:



134
135
136
# File 'lib/vedeu/dsl/components/border.rb', line 134

def show_bottom!
  bottom(true)
end

#show_left!Object

See Also:



164
165
166
# File 'lib/vedeu/dsl/components/border.rb', line 164

def show_left!
  left(true)
end

#show_right!Object

See Also:



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

def show_right!
  right(true)
end

#show_top!Object

See Also:



224
225
226
# File 'lib/vedeu/dsl/components/border.rb', line 224

def show_top!
  top(true)
end

#top(boolean) ⇒ Boolean Also known as: show_top

Enable/disable the top border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      top false
      # ... or
      hide_top!
      # ... or
      show_top!

Parameters:

  • boolean (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


213
214
215
# File 'lib/vedeu/dsl/components/border.rb', line 213

def top(boolean)
  model.show_top = !!boolean
end

#top_left(char) ⇒ String

Set the character to be used to draw the top left corner of the border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      top_left '+'
      # ...

Parameters:

  • char (String)

    Character to be used as the top left border character.

Returns:

  • (String)


240
241
242
# File 'lib/vedeu/dsl/components/border.rb', line 240

def top_left(char)
  model.top_left = char
end

#top_right(char) ⇒ String

Set the character to be used to draw the top right corner of the border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      top_right '+'
      # ...

Parameters:

  • char (String)

    Character to be used as the top right border character.

Returns:

  • (String)


256
257
258
# File 'lib/vedeu/dsl/components/border.rb', line 256

def top_right(char)
  model.top_right = char
end

#vertical(char) ⇒ String

Set the character to be used to draw a vertical part of the border.

Examples:

Vedeu.renders do
  view 'border_demo' do
    border do
      vertical '|'
      # ...

Parameters:

  • char (String)

    Character to be used as the vertical border character.

Returns:

  • (String)


272
273
274
# File 'lib/vedeu/dsl/components/border.rb', line 272

def vertical(char)
  model.vertical = char
end