Class: Vedeu::Style
- Inherits:
-
Object
- Object
- Vedeu::Style
- Defined in:
- lib/vedeu/output/style.rb
Overview
Converts the style value or value collection into a terminal escape sequence. Unrecognised values are discarded- an empty string is returned.
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#attributes ⇒ Hash
Return an attributes hash for this class.
-
#initialize(value = nil) ⇒ Style
constructor
Return a new instance of Style.
-
#to_s ⇒ String
(also: #escape_sequences)
Return the terminal escape sequences after converting the style or styles.
Methods included from Coercions
Methods included from Common
Constructor Details
#initialize(value = nil) ⇒ Style
Return a new instance of Style.
21 22 23 |
# File 'lib/vedeu/output/style.rb', line 21 def initialize(value = nil) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
14 15 16 |
# File 'lib/vedeu/output/style.rb', line 14 def value @value end |
Instance Method Details
#attributes ⇒ Hash
Return an attributes hash for this class.
28 29 30 31 32 |
# File 'lib/vedeu/output/style.rb', line 28 def attributes { style: value } end |
#to_s ⇒ String Also known as: escape_sequences
Return the terminal escape sequences after converting the style or styles.
37 38 39 40 41 |
# File 'lib/vedeu/output/style.rb', line 37 def to_s return '' unless defined_value?(value) @sequences ||= Array(value).flatten.map { |v| Esc.string(v) }.join end |