Class: Vedeu::Models::Escape
- Inherits:
-
Object
- Object
- Vedeu::Models::Escape
- Defined in:
- lib/vedeu/models/escape.rb
Overview
Represents an invisible escape character sequence.
Instance Attribute Summary collapse
- #value ⇒ String readonly
Instance Method Summary collapse
- #defaults ⇒ Hash private
-
#eql?(other) ⇒ Boolean
(also: #==)
An object is equal when its values are the same.
-
#initialize(attributes = {}) ⇒ Vedeu::Models::Escape
constructor
Returns a new instance of Vedeu::Models::Escape.
- #null ⇒ NilClass (also: #background, #colour, #foreground, #style)
- #position ⇒ String
-
#to_hash ⇒ Hash<void>
Return an empty hash as most escape sequences won’t make sense as JSON.
-
#to_html(_options = {}) ⇒ String
Return an empty string as most escape sequences won’t make sense as HTML.
- #to_s ⇒ String (also: #to_str)
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Models::Escape
Returns a new instance of Vedeu::Models::Escape.
20 21 22 23 24 |
# File 'lib/vedeu/models/escape.rb', line 20 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#value ⇒ String (readonly)
11 12 13 |
# File 'lib/vedeu/models/escape.rb', line 11 def value @value end |
Instance Method Details
#defaults ⇒ Hash (private)
75 76 77 78 79 80 |
# File 'lib/vedeu/models/escape.rb', line 75 def defaults { position: [1, 1], value: '', } end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
39 40 41 |
# File 'lib/vedeu/models/escape.rb', line 39 def eql?(other) self.class == other.class && value == other.value end |
#null ⇒ NilClass Also known as: background, colour, foreground, style
27 28 29 |
# File 'lib/vedeu/models/escape.rb', line 27 def null nil end |
#position ⇒ String
45 46 47 |
# File 'lib/vedeu/models/escape.rb', line 45 def position Vedeu::Geometry::Position.coerce(@position) end |
#to_hash ⇒ Hash<void>
Return an empty hash as most escape sequences won’t make sense as JSON.
53 54 55 |
# File 'lib/vedeu/models/escape.rb', line 53 def to_hash {} end |
#to_html(_options = {}) ⇒ String
Return an empty string as most escape sequences won’t make sense as HTML.
62 63 64 |
# File 'lib/vedeu/models/escape.rb', line 62 def to_html( = {}) '' end |
#to_s ⇒ String Also known as: to_str
67 68 69 |
# File 'lib/vedeu/models/escape.rb', line 67 def to_s "#{position}#{value}" end |