Class: Vedeu::Borders::DSL
- Inherits:
-
Object
- Object
- Vedeu::Borders::DSL
- 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
-
#client ⇒ Object
included
from DSL
readonly
protected
The object instance where the DSL is being used.
-
#model ⇒ void
included
from DSL
readonly
protected
The new model object which the DSL is constructing.
Class Method Summary collapse
Instance Method Summary collapse
-
#attributes ⇒ Hash<Symbol => void>
included
from DSL
private
Returns the default attributes for the new model.
- #attrs(value, options) ⇒ Hash<Symbol => void> private
-
#background(value = '') ⇒ String
(also: #bg, #bgcolor, #background=, #bg=, #bgcolor=)
included
from DSL::Presentation
Define the background colour for an interface, line, or a stream.
-
#bottom(value) ⇒ Boolean
(also: #show_bottom, #bottom=)
and false.
-
#bottom_horizontal(char, options = {}) ⇒ String
(also: #bottom_horizontal=)
-
#bottom_left(char, options = {}) ⇒ String
(also: #bottom_left=)
-
#bottom_right(char, options = {}) ⇒ String
(also: #bottom_right=)
-
#caption(value) ⇒ String
(also: #caption=)
-
#colour(attrs = {}) ⇒ Vedeu::Colours::Colour
(also: #colour=)
included
from DSL::Presentation
Define either or both foreground and background colours for an interface, line or a stream.
- #colour_attributes ⇒ Hash<Symbol => String> included from DSL::Presentation private
- #default_options ⇒ Hash<Symbol => NilClass|String|Symbol> private
-
#disable! ⇒ Boolean
(also: #disabled!)
-
#enable! ⇒ Boolean
(also: #enabled!)
- #foreground(value = '') ⇒ Object (also: #fg, #fgcolor, #foreground=, #fg=, #fgcolor=) included from DSL::Presentation
-
#hide_bottom! ⇒ Object
Disable the bottom border.
-
#hide_left! ⇒ Object
Disable the left border.
-
#hide_right! ⇒ Object
Disable the right border.
-
#hide_top! ⇒ Object
Disable the top border.
-
#horizontal(char, options = {}) ⇒ String
(also: #horizontal=)
-
#initialize(model, client = nil) ⇒ void
included
from DSL
Returns a new instance of the DSL class including DSL.
-
#left(value) ⇒ Boolean
(also: #show_left, #left=)
-
#left_vertical(char, options = {}) ⇒ String
(also: #left_vertical=)
-
#method_missing(method, *args, &block) ⇒ void
included
from DSL
private
Attempts to find the missing method on the client object.
-
#name ⇒ NilClass|String|Symbol
included
from DSL
Returns the model name if available.
-
#right(value) ⇒ Boolean
(also: #show_right, #right=)
-
#right_vertical(char, options = {}) ⇒ String
(also: #right_vertical=)
-
#show_bottom! ⇒ Object
Enable the bottom border.
-
#show_left! ⇒ Object
Enable the left border.
-
#show_right! ⇒ Object
Enable the right border.
-
#show_top! ⇒ Object
Enable the top border.
-
#style(value) ⇒ Vedeu::Presentation::Style
(also: #style=, #styles, #styles=)
included
from DSL::Presentation
Define a style or styles for an interface, line or a stream.
-
#title(value) ⇒ String
(also: #title=)
-
#top(value) ⇒ Boolean
(also: #show_top, #top=)
-
#top_horizontal(char, options = {}) ⇒ String
(also: #top_horizontal=)
-
#top_left(char, options = {}) ⇒ String
(also: #top_left=)
-
#top_right(char, options = {}) ⇒ String
(also: #top_right=)
-
#use(name) ⇒ void
included
from DSL::Use
Use the attribute of stored model.
-
#vertical(char, options = {}) ⇒ String
(also: #vertical=)
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Instance Attribute Details
#client ⇒ Object (readonly, protected) Originally defined in module DSL
Returns The object instance where the DSL is being used.
#model ⇒ void (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
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
#attributes ⇒ Hash<Symbol => void> (private) Originally defined in module DSL
Specific DSL classes may be overriding this method.
Returns the default attributes for the new model.
#attrs(value, options) ⇒ Hash<Symbol => void> (private)
317 318 319 |
# File 'lib/vedeu/borders/dsl.rb', line 317 def attrs(value, ) .merge!(value: value).merge!() end |
#background(value = '') ⇒ String Also known as: bg, bgcolor, background=, bg=, bgcolor= Originally defined in module DSL::Presentation
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.
#bottom(value) ⇒ Boolean Also known as: show_bottom, bottom=
and false.
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=
106 107 108 109 |
# File 'lib/vedeu/borders/dsl.rb', line 106 def bottom_horizontal(char, = {}) model.bottom_horizontal = Vedeu::Cells::BottomHorizontal .new(attrs(char, )) end |
#bottom_left(char, options = {}) ⇒ String Also known as: bottom_left=
38 39 40 |
# File 'lib/vedeu/borders/dsl.rb', line 38 def bottom_left(char, = {}) model.bottom_left = Vedeu::Cells::BottomLeft.new(attrs(char, )) end |
#bottom_right(char, options = {}) ⇒ String Also known as: bottom_right=
51 52 53 |
# File 'lib/vedeu/borders/dsl.rb', line 51 def bottom_right(char, = {}) model.bottom_right = Vedeu::Cells::BottomRight.new(attrs(char, )) end |
#caption(value) ⇒ String Also known as: caption=
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
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.
#colour_attributes ⇒ Hash<Symbol => String> (private) Originally defined in module DSL::Presentation
#default_options ⇒ Hash<Symbol => NilClass|String|Symbol> (private)
322 323 324 325 326 327 328 329 |
# File 'lib/vedeu/borders/dsl.rb', line 322 def { colour: model.colour, name: model.name, style: model.style, value: nil, } end |
#disable! ⇒ Boolean Also known as: disabled!
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!
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
#hide_bottom! ⇒ Object
Disable the bottom border.
140 141 142 |
# File 'lib/vedeu/borders/dsl.rb', line 140 def hide_bottom! bottom(false) end |
#hide_left! ⇒ Object
Disable the left border.
166 167 168 |
# File 'lib/vedeu/borders/dsl.rb', line 166 def hide_left! left(false) end |
#hide_right! ⇒ Object
Disable the right border.
192 193 194 |
# File 'lib/vedeu/borders/dsl.rb', line 192 def hide_right! right(false) end |
#hide_top! ⇒ Object
Disable the top border.
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=
120 121 122 |
# File 'lib/vedeu/borders/dsl.rb', line 120 def horizontal(char, = {}) model.horizontal = Vedeu::Cells::Horizontal.new(attrs(char, )) end |
#initialize(model, client = nil) ⇒ void Originally defined in module DSL
Returns a new instance of the DSL class including Vedeu::DSL.
#left(value) ⇒ Boolean Also known as: show_left, left=
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=
281 282 283 284 |
# File 'lib/vedeu/borders/dsl.rb', line 281 def left_vertical(char, = {}) model.left_vertical = Vedeu::Cells::LeftVertical .new(attrs(char, )) end |
#name ⇒ NilClass|String|Symbol Originally defined in module DSL
Returns the model name if available.
#right(value) ⇒ Boolean Also known as: show_right, right=
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=
295 296 297 298 |
# File 'lib/vedeu/borders/dsl.rb', line 295 def right_vertical(char, = {}) model.right_vertical = Vedeu::Cells::RightVertical .new(attrs(char, )) end |
#show_bottom! ⇒ Object
Enable the bottom border.
147 148 149 |
# File 'lib/vedeu/borders/dsl.rb', line 147 def show_bottom! bottom(true) end |
#show_left! ⇒ Object
Enable the left border.
173 174 175 |
# File 'lib/vedeu/borders/dsl.rb', line 173 def show_left! left(true) end |
#show_right! ⇒ Object
Enable the right border.
199 200 201 |
# File 'lib/vedeu/borders/dsl.rb', line 199 def show_right! right(true) end |
#show_top! ⇒ Object
Enable the top border.
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.
#title(value) ⇒ String Also known as: title=
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=
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=
92 93 94 95 |
# File 'lib/vedeu/borders/dsl.rb', line 92 def top_horizontal(char, = {}) model.top_horizontal = Vedeu::Cells::TopHorizontal .new(attrs(char, )) end |
#top_left(char, options = {}) ⇒ String Also known as: top_left=
255 256 257 |
# File 'lib/vedeu/borders/dsl.rb', line 255 def top_left(char, = {}) model.top_left = Vedeu::Cells::TopLeft.new(attrs(char, )) end |
#top_right(char, options = {}) ⇒ String Also known as: top_right=
268 269 270 |
# File 'lib/vedeu/borders/dsl.rb', line 268 def top_right(char, = {}) model.top_right = Vedeu::Cells::TopRight.new(attrs(char, )) end |
#use(name) ⇒ void Originally defined in module DSL::Use
-
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.
#vertical(char, options = {}) ⇒ String Also known as: vertical=
309 310 311 |
# File 'lib/vedeu/borders/dsl.rb', line 309 def vertical(char, = {}) model.vertical = Vedeu::Cells::Vertical.new(attrs(char, )) end |