Class: Vedeu::DSL::Border

Inherits:
Object
  • Object
show all
Includes:
Vedeu::DSL, Presentation
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 when defining your interface...
Vedeu.interface 'my_interface' do
  border do
    # ...

# ...or 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 Presentation

#background, #colour, #foreground, #style

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)


56
57
58
59
# File 'lib/vedeu/dsl/components/border.rb', line 56

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

Returns:

  • (Object)


325
326
327
# File 'lib/vedeu/dsl/components/border.rb', line 325

def client
  @client
end

#modelBorder (readonly, protected)

Returns:



329
330
331
# File 'lib/vedeu/dsl/components/border.rb', line 329

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.



45
46
47
48
49
# File 'lib/vedeu/dsl/components/border.rb', line 45

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(value) ⇒ 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:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


126
127
128
129
130
# File 'lib/vedeu/dsl/components/border.rb', line 126

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

  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)


74
75
76
# File 'lib/vedeu/dsl/components/border.rb', line 74

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)


91
92
93
# File 'lib/vedeu/dsl/components/border.rb', line 91

def bottom_right(char)
  model.bottom_right = char
end

#hide_bottom!Object

Disable the bottom border.

See Also:



136
137
138
# File 'lib/vedeu/dsl/components/border.rb', line 136

def hide_bottom!
  bottom(false)
end

#hide_left!Object

Disable the left border.

See Also:



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

def hide_left!
  left(false)
end

#hide_right!Object

Disable the right border.

See Also:



208
209
210
# File 'lib/vedeu/dsl/components/border.rb', line 208

def hide_right!
  right(false)
end

#hide_top!Object

Disable the top border.

See Also:



262
263
264
# File 'lib/vedeu/dsl/components/border.rb', line 262

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)


107
108
109
# File 'lib/vedeu/dsl/components/border.rb', line 107

def horizontal(char)
  model.horizontal = char
end

#left(value) ⇒ 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:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


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

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

  model.show_left = boolean
end

#right(value) ⇒ 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:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


198
199
200
201
202
# File 'lib/vedeu/dsl/components/border.rb', line 198

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

  model.show_right = boolean
end

#show_bottom!Object

Enable the bottom border.

See Also:



143
144
145
# File 'lib/vedeu/dsl/components/border.rb', line 143

def show_bottom!
  bottom(true)
end

#show_left!Object

Enable the left border.

See Also:



179
180
181
# File 'lib/vedeu/dsl/components/border.rb', line 179

def show_left!
  left(true)
end

#show_right!Object

Enable the right border.

See Also:



215
216
217
# File 'lib/vedeu/dsl/components/border.rb', line 215

def show_right!
  right(true)
end

#show_top!Object

Enable the top border.

See Also:



269
270
271
# File 'lib/vedeu/dsl/components/border.rb', line 269

def show_top!
  top(true)
end

#title(value) ⇒ String

If you have you are showing a top border, you could add a title.

Examples:

Vedeu.renders do
  view 'border_demo' do
    geometry { width: 50 }
    border do
      title 'My Cool Title'
      # ...

+- My Cool Title --------------------------------+

Parameters:

  • value (String)

    The title.

Returns:

  • (String)


233
234
235
# File 'lib/vedeu/dsl/components/border.rb', line 233

def title(value)
  model.title = value
end

#top(value) ⇒ 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:

  • value (Boolean)

    All values evaluate as true except nil and false.

Returns:

  • (Boolean)


252
253
254
255
256
# File 'lib/vedeu/dsl/components/border.rb', line 252

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

  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)


285
286
287
# File 'lib/vedeu/dsl/components/border.rb', line 285

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)


301
302
303
# File 'lib/vedeu/dsl/components/border.rb', line 301

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)


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

def vertical(char)
  model.vertical = char
end