Class: Vedeu::Models::Cell Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/models/cell.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.

A Cell represents a single square of the terminal.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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.

Note:

If a particular key is missing from the attributes parameter, then it is added with the respective value from #defaults.

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

Parameters:

  • attributes (Hash<Symbol => Array<Symbol|String>, Fixnum, String, Symbol]) (defaults to: {})

    ttributes [Hash<Symbol => Array<Symbol|String>, Fixnum, String, Symbol]

Options Hash (attributes):

  • colour (NilClass|String)
  • style (Object)
    NilClass|Array<Symbol|String>|Symbol|String
  • value (NilClass|String)
  • position (Vedeu::Geometry::Position)


42
43
44
45
46
# File 'lib/vedeu/models/cell.rb', line 42

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value || defaults.fetch(key))
  end
end

Instance Attribute Details

#colourNilClass|String (readonly)

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.

Returns:

  • (NilClass|String)


13
14
15
# File 'lib/vedeu/models/cell.rb', line 13

def colour
  @colour
end

#nameString|Symbol (readonly)

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.

Returns:

  • (String|Symbol)


17
18
19
# File 'lib/vedeu/models/cell.rb', line 17

def name
  @name
end

#styleNilClass|Array<Symbol|String>|Symbol|String (readonly)

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.

Returns:

  • (NilClass|Array<Symbol|String>|Symbol|String)


21
22
23
# File 'lib/vedeu/models/cell.rb', line 21

def style
  @style
end

#valueNilClass|String (readonly)

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.

Returns:

  • (NilClass|String)


25
26
27
# File 'lib/vedeu/models/cell.rb', line 25

def value
  @value
end

Instance Method Details

#cell?Boolean

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.

Returns:

  • (Boolean)


49
50
51
# File 'lib/vedeu/models/cell.rb', line 49

def cell?
  true
end

#defaultsHash<Symbol => void> (private)

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.

Returns the default options/attributes for this class.

Returns:

  • (Hash<Symbol => void>)


99
100
101
102
103
104
105
106
107
# File 'lib/vedeu/models/cell.rb', line 99

def defaults
  {
    colour:   nil,
    name:     nil,
    style:    nil,
    value:    '',
    position: [1, 1],
  }
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.

Parameters:

Returns:

  • (Boolean)


57
58
59
60
# File 'lib/vedeu/models/cell.rb', line 57

def eql?(other)
  self.class == other.class && value == other.value &&
    position == other.position
end

#interfaceVedeu::Interfaces::Interface

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.



64
65
66
# File 'lib/vedeu/models/cell.rb', line 64

def interface
  @interface ||= Vedeu.interfaces.by_name(name)
end

#positionVedeu::Geometry::Position

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.



69
70
71
# File 'lib/vedeu/models/cell.rb', line 69

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

#to_hashHash

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.

Returns:

  • (Hash)


74
75
76
77
78
79
80
81
# File 'lib/vedeu/models/cell.rb', line 74

def to_hash
  {
    colour:   colour.to_s,
    style:    style.to_s,
    value:    value.to_s,
    position: position.to_s,
  }
end

#to_html(_options = {}) ⇒ 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.

Parameters:

  • _options (Hash) (defaults to: {})

    Ignored.

Returns:

  • (String)


85
86
87
# File 'lib/vedeu/models/cell.rb', line 85

def to_html(_options = {})
  ''
end

#to_sString

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.

Returns:

  • (String)


90
91
92
# File 'lib/vedeu/models/cell.rb', line 90

def to_s
  value.to_s
end