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
- #align ⇒ Vedeu::Coercers::Alignment private private
- #attributes ⇒ Hash private
-
#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<Symbol => void>
private
private
The default options/attributes for a new instance of this class.
-
#geometry ⇒ Vedeu::Geometries::Geometry
private
private
Returns the named geometry from the geometries repository.
- #initialize(context = nil, model = nil, value = '', options = {}, &block) ⇒ Vedeu::DSL::Attributes constructor private
- #model_colour ⇒ Hash private private
- #name ⇒ NilClass|String|Symbol private private
- #new_colour_options ⇒ Hash private private
- #options ⇒ Hash private private
- #pad ⇒ String private private
- #style ⇒ NilClass|Vedeu::Presentation::Style private private
- #truncate ⇒ Boolean private private
- #value ⇒ Hash<Symbol => String> private private
- #width ⇒ Fixnum|NilClass private private
- #wordwrap ⇒ Boolean private private
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
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.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 49 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.
88 89 90 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 88 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.
80 81 82 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 80 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.
84 85 86 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 84 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
#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.
93 94 95 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 93 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.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 62 def attributes { align: align, client: client, colour: colour, name: name, pad: pad, style: style, truncate: truncate, width: width, wordwrap: wordwrap, }.merge!(value) end |
#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.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 100 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.
210 211 212 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 210 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.
116 117 118 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 116 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.
200 201 202 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 200 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.
205 206 207 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 205 def .select { |k, _| colour_attributes.include?(k) } end |
#defaults ⇒ Hash<Symbol => void> (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.
The default options/attributes for a new instance of this class.
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 121 def defaults { align: :none, client: nil, colour: nil, name: nil, pad: ' ', style: nil, truncate: false, width: nil, wordwrap: true, } end |
#geometry ⇒ 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.
Returns the named geometry from the geometries repository.
136 137 138 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 136 def geometry @_geometry ||= Vedeu.geometries.by_name(name) end |
#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.
215 216 217 218 219 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 215 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.
141 142 143 144 145 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 141 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.
222 223 224 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 222 def model_colour.merge() end |
#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.
148 149 150 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 148 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.
153 154 155 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 153 def pad [:pad].to_s[0] || ' ' end |
#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.
158 159 160 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 158 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.
163 164 165 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 163 def truncate truthy?([:truncate]) end |
#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.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 168 def value if block {} elsif absent?(@value) {} else { value: @value, } end end |
#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.
184 185 186 187 188 189 190 191 192 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 184 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.
195 196 197 |
# File 'lib/vedeu/dsl/helpers/attributes.rb', line 195 def wordwrap truthy?([:wordwrap]) end |