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
- #cell? ⇒ Boolean
- #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
#cell? ⇒ Boolean
27 28 29 |
# File 'lib/vedeu/models/escape.rb', line 27 def cell? false end |
#defaults ⇒ Hash (private)
80 81 82 83 84 85 |
# File 'lib/vedeu/models/escape.rb', line 80 def defaults { position: [1, 1], value: '', } end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
44 45 46 |
# File 'lib/vedeu/models/escape.rb', line 44 def eql?(other) self.class == other.class && value == other.value end |
#null ⇒ NilClass Also known as: background, colour, foreground, style
32 33 34 |
# File 'lib/vedeu/models/escape.rb', line 32 def null nil end |
#position ⇒ String
50 51 52 |
# File 'lib/vedeu/models/escape.rb', line 50 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.
58 59 60 |
# File 'lib/vedeu/models/escape.rb', line 58 def to_hash {} end |
#to_html(_options = {}) ⇒ String
Return an empty string as most escape sequences won’t make sense as HTML.
67 68 69 |
# File 'lib/vedeu/models/escape.rb', line 67 def to_html( = {}) ''.freeze end |
#to_s ⇒ String Also known as: to_str
72 73 74 |
# File 'lib/vedeu/models/escape.rb', line 72 def to_s "#{position}#{value}".freeze end |