Class: Vedeu::DSL::Attributes Private
- Inherits:
-
Object
- Object
- Vedeu::DSL::Attributes
- Includes:
- Common
- Defined in:
- lib/vedeu/dsl/helpers/attributes.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Creates attributes for DSL objects.
Instance Attribute Summary collapse
- #block ⇒ NilClass|Proc readonly protected private
- #context ⇒ NilClass|Vedeu::DSL::Elements readonly protected private
- #model ⇒ NilClass|Vedeu::Views::* readonly protected private
Class Method Summary collapse
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
- #align ⇒ Vedeu::Coercers::Alignment private private
- #attributes ⇒ Hash private
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
-
#client ⇒ Object
private
private
Returns the client object which called the DSL method.
- #coerce_colour_options ⇒ Hash private private
- #colour ⇒ Vedeu::Colours::Colour private private
- #colour_attributes ⇒ Array<Symbol> private private
- #colour_options ⇒ Hash private private
- #defaults ⇒ Hash private private
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
- #geometry ⇒ NilClass|Vedeu::Geometries::Geometry private private
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
- #initialize(context = nil, model = nil, value = '', options = {}, &block) ⇒ Vedeu::DSL::Attributes constructor private
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
- #model_colour ⇒ Hash private private
- #name ⇒ NilClass|String|Symbol private private
- #new_colour_options ⇒ Hash private private
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- #options ⇒ Hash private private
- #pad ⇒ String private private
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- #style ⇒ NilClass|Vedeu::Presentation::Style private private
- #truncate ⇒ Boolean private private
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
- #value ⇒ Hash<Symbol => String> private private
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
- #width ⇒ Fixnum|NilClass private private
- #wordwrap ⇒ Boolean private private
Constructor Details
#initialize(context = nil, model = nil, value = '', options = {}, &block) ⇒ Vedeu::DSL::Attributes
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 45 def initialize(context = nil, model = nil, value = '', = {}, &block) @context = context @model = model @value = value || '' @options = || {} @block = block end |
Instance Attribute Details
#block ⇒ NilClass|Proc (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 84 def block @block end |
#context ⇒ NilClass|Vedeu::DSL::Elements (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 76 def context @context end |
#model ⇒ NilClass|Vedeu::Views::* (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 80 def model @model end |
Class Method Details
.build(context = nil, model = nil, value = '', options = {}, &block) ⇒ Hash<Symbol => void>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 17 def self.build(context = nil, model = nil, value = '', = {}, &block) new(context, model, value, , &block).attributes end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
#align ⇒ Vedeu::Coercers::Alignment (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 89 def align Vedeu::Coercers::Alignment.coerce([:align]) end |
#attributes ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 58 def attributes { align: align, client: client, colour: colour, name: name, pad: pad, style: style, truncate: truncate, width: width, wordwrap: wordwrap, }.merge!(value) end |
#become(klass, attributes) ⇒ Class Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts one class into another.
#boolean(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the value was a boolean.
#boolean?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Boolean.
#client ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the client object which called the DSL method.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 96 def client if block if eval('client', block.binding).nil? eval(context.class.name, block.binding) else eval('client', block.binding) end elsif present?(model) model.client end end |
#coerce_colour_options ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
206 207 208 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 206 def Vedeu::Coercers::ColourAttributes.coerce() end |
#colour ⇒ Vedeu::Colours::Colour (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
112 113 114 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 112 def colour Vedeu::Colours::Colour.coerce() end |
#colour_attributes ⇒ Array<Symbol> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
196 197 198 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 196 def colour_attributes [:background, :colour, :foreground] end |
#colour_options ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
201 202 203 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 201 def .select { |k, _| colour_attributes.include?(k) } end |
#defaults ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 117 def defaults { align: :none, client: nil, colour: nil, name: nil, pad: ' ', style: nil, truncate: false, width: nil, wordwrap: false, } end |
#escape?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
#falsy?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered false.
#geometry ⇒ NilClass|Vedeu::Geometries::Geometry (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
132 133 134 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 132 def geometry @_geometry ||= Vedeu.geometries.by_name(name) end |
#hash?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Hash.
#line_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Line.
#model_colour ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
211 212 213 214 215 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 211 def model_colour return {} unless present?(model) && model.colour model.colour.attributes end |
#name ⇒ NilClass|String|Symbol (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
137 138 139 140 141 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 137 def name return model.name if present?(model) && present?(model.name) nil end |
#new_colour_options ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
218 219 220 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 218 def model_colour.merge() end |
#numeric?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
#options ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
144 145 146 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 144 def defaults.merge!(@options) end |
#pad ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
149 150 151 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 149 def pad [:pad].to_s[0] || ' ' end |
#present?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
#snake_case(klass) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
#stream_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Stream.
#string?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
#style ⇒ NilClass|Vedeu::Presentation::Style (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
154 155 156 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 154 def style Vedeu::Presentation::Style.coerce([:style]) end |
#truncate ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
159 160 161 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 159 def truncate truthy?([:truncate]) end |
#truthy?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered true.
#value ⇒ Hash<Symbol => String> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 164 def value if block {} elsif absent?(@value) {} else { value: @value, } end end |
#view_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::View.
#width ⇒ Fixnum|NilClass (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
180 181 182 183 184 185 186 187 188 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 180 def width if numeric?([:width]) [:width] elsif view_model? && name geometry.bordered_width end end |
#wordwrap ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
191 192 193 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 191 def wordwrap truthy?([:wordwrap]) end |