Class: Vedeu::Presentation::Style Private
- Inherits:
-
Object
- Object
- Vedeu::Presentation::Style
- Extended by:
- Forwardable
- Includes:
- Common
- Defined in:
- lib/vedeu/presentation/style.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.
Converts the style value or value collection into a terminal escape sequence. Unrecognised values are discarded- an empty string is returned.
Vedeu has a range of symbol styles which are compatible with most terminals which are ANSI compatible. Like colours, they can be defined in either interfaces, for specific lines or within streams. Styles are applied as encountered.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#attributes ⇒ Hash<Symbol => Array<String|Symbol>|String|Symbol>
private
Return an attributes hash for this class.
-
#eql?(other) ⇒ Boolean
(also: #==)
private
An object is equal when its values are the same.
-
#initialize(value = nil) ⇒ Vedeu::Presentation::Style
constructor
private
Return a new instance of Vedeu::Presentation::Style.
- #to_ast ⇒ String private
-
#to_s ⇒ String
(also: #escape_sequences, #to_str)
private
Return the terminal escape sequences after converting the style or styles.
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(value = nil) ⇒ Vedeu::Presentation::Style
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 a new instance of Vedeu::Presentation::Style.
42 43 44 |
# File 'lib/vedeu/presentation/style.rb', line 42 def initialize(value = nil) @value = value end |
Instance Attribute Details
#value ⇒ String|Symbol
35 36 37 |
# File 'lib/vedeu/presentation/style.rb', line 35 def value @value end |
Instance Method Details
#attributes ⇒ Hash<Symbol => Array<String|Symbol>|String|Symbol>
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 an attributes hash for this class.
49 50 51 52 53 |
# File 'lib/vedeu/presentation/style.rb', line 49 def attributes { style: value, } end |
#eql?(other) ⇒ Boolean Also known as: ==
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.
An object is equal when its values are the same.
59 60 61 |
# File 'lib/vedeu/presentation/style.rb', line 59 def eql?(other) self.class.equal?(other.class) && value == other.value end |
#to_ast ⇒ 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.
65 66 67 |
# File 'lib/vedeu/presentation/style.rb', line 65 def to_ast ':s' end |
#to_s ⇒ String Also known as: escape_sequences, to_str
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 terminal escape sequences after converting the style or styles.
73 74 75 76 77 |
# File 'lib/vedeu/presentation/style.rb', line 73 def to_s return '' unless present?(value) @sequences ||= Array(value).flat_map { |v| Vedeu.esc.string(v) }.join end |