Class: Vedeu::DSL::Truncate Private
- Inherits:
-
Object
- Object
- Vedeu::DSL::Truncate
- Includes:
- Common
- Defined in:
- lib/vedeu/dsl/helpers/truncate.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.
Truncates a string to an optional width, or uses the named geometry width.
Instance Attribute Summary collapse
-
#options ⇒ Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol]
readonly
protected
private
Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol].
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#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.
-
#defaults ⇒ Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol]
private
private
Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol].
-
#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 ⇒ Vedeu::Geometries::Geometry private private
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(value = '', options = {}) ⇒ Vedeu::DSL::Truncate
constructor
private
Returns a new instance of Vedeu::DSL::Truncate.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#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.
- #text ⇒ String private
- #truncate ⇒ String 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 ⇒ String private private
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
-
#width ⇒ Fixnum
private
private
Return the width of the interface when a name is given, otherwise use the given width.
Constructor Details
#initialize(value = '', options = {}) ⇒ Vedeu::DSL::Truncate
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 new instance of Vedeu::DSL::Truncate.
28 29 30 31 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 28 def initialize(value = '', = {}) @value = value || '' = defaults.merge!() end |
Instance Attribute Details
#options ⇒ Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol] (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.
Returns Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol].
49 50 51 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 49 def 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.
#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.
#defaults ⇒ Hash<Symbol => Boolean|Fixnum|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.
Returns Hash<Symbol => Boolean|Fixnum|NilClass|String| Symbol].
55 56 57 58 59 60 61 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 55 def defaults { name: nil, truncate: false, width: nil, } 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 ⇒ 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.
64 65 66 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 64 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.
#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.
#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.
#text ⇒ String
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.
34 35 36 37 38 39 40 41 42 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 34 def text if truncate? truncate else value end end |
#truncate ⇒ 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.
74 75 76 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 74 def truncate value.slice(0, width) 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.
69 70 71 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 69 def truncate? truthy?([:truncate]) && value.size > width 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 ⇒ 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.
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 79 def value if present?(@value) && string?(@value) @value elsif present?(@value) @value.to_s else '' 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 (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.
Return the width of the interface when a name is given, otherwise use the given width.
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/vedeu/dsl/helpers/truncate.rb', line 96 def width if present?([:width]) [:width] elsif present?([:name]) geometry.bordered_width else value.size end end |