Class: Vedeu::Models::Escape

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/models/escape.rb

Overview

Represents an invisible escape character sequence.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Models::Escape

Returns a new instance of Vedeu::Models::Escape.

Options Hash (attributes):

  • position (Object)
    Vedeu::Geometry::Position|Array<Fixnum>
  • value (String)


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

#valueString (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

#defaultsHash (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

#nullNilClass Also known as: background, colour, foreground, style



32
33
34
# File 'lib/vedeu/models/escape.rb', line 32

def null
  nil
end

#positionString



50
51
52
# File 'lib/vedeu/models/escape.rb', line 50

def position
  Vedeu::Geometry::Position.coerce(@position)
end

#to_hashHash<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(_options = {})
  ''.freeze
end

#to_sString Also known as: to_str



72
73
74
# File 'lib/vedeu/models/escape.rb', line 72

def to_s
  "#{position}#{value}".freeze
end