Class: Vedeu::Char
- Inherits:
-
Object
- Object
- Vedeu::Char
- Includes:
- Presentation
- Defined in:
- lib/vedeu/models/view/char.rb
Overview
A Char represents a single character of the terminal. It is a container for the a single character in a Stream.
Though a multi-character String can be passed as a value, only the first character is returned in the escape sequence.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
private
Returns the value of attribute attributes.
-
#border ⇒ Object
Returns the value of attribute border.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#defaults ⇒ Hash
private
The default values for a new instance of this class.
- #eql?(other) ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Char
constructor
Returns a new instance of Char.
- #position ⇒ Vedeu::Position
- #position=(value) ⇒ Vedeu::Position
- #to_html ⇒ String
- #x ⇒ Fixnum|NilClass
- #y ⇒ Fixnum|NilClass
Methods included from Presentation
#background, #colour, #colour=, #foreground, #parent_background, #parent_colour, #parent_foreground, #parent_style, #render_border, #render_colour, #render_position, #render_style, #style, #style=, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ Char
Returns a new instance of Char.
31 32 33 34 35 36 37 38 39 |
# File 'lib/vedeu/models/view/char.rb', line 31 def initialize(attributes = {}) @attributes = defaults.merge!(attributes) @border = @attributes[:border] @colour = @attributes[:colour] @parent = @attributes[:parent] @style = @attributes[:style] @value = @attributes[:value] end |
Instance Attribute Details
#attributes ⇒ Object (readonly, private)
Returns the value of attribute attributes.
81 82 83 |
# File 'lib/vedeu/models/view/char.rb', line 81 def attributes @attributes end |
#border ⇒ Object
Returns the value of attribute border.
16 17 18 |
# File 'lib/vedeu/models/view/char.rb', line 16 def border @border end |
#parent ⇒ Object
Returns the value of attribute parent.
16 17 18 |
# File 'lib/vedeu/models/view/char.rb', line 16 def parent @parent end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
19 20 21 |
# File 'lib/vedeu/models/view/char.rb', line 19 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
43 44 45 |
# File 'lib/vedeu/models/view/char.rb', line 43 def ==(other) eql?(other) end |
#defaults ⇒ Hash (private)
The default values for a new instance of this class.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/vedeu/models/view/char.rb', line 86 def defaults { border: nil, colour: nil, parent: nil, position: nil, style: nil, value: '', } end |
#eql?(other) ⇒ Boolean
49 50 51 |
# File 'lib/vedeu/models/view/char.rb', line 49 def eql?(other) self.class == other.class && value == other.value end |
#position ⇒ Vedeu::Position
54 55 56 |
# File 'lib/vedeu/models/view/char.rb', line 54 def position @position ||= Vedeu::Position.coerce(attributes[:position]) end |
#position=(value) ⇒ Vedeu::Position
60 61 62 |
# File 'lib/vedeu/models/view/char.rb', line 60 def position=(value) @position = Vedeu::Position.coerce(value) end |
#to_html ⇒ String
75 76 77 |
# File 'lib/vedeu/models/view/char.rb', line 75 def to_html @to_html ||= HTMLChar.render(self) end |
#x ⇒ Fixnum|NilClass
65 66 67 |
# File 'lib/vedeu/models/view/char.rb', line 65 def x position.x if position end |
#y ⇒ Fixnum|NilClass
70 71 72 |
# File 'lib/vedeu/models/view/char.rb', line 70 def y position.y if position end |