Class: Vedeu::Views::Line
- Inherits:
-
Object
- Object
- Vedeu::Views::Line
- Includes:
- Model, Presentation
- Defined in:
- lib/vedeu/models/views/line.rb
Overview
Represents a single row of the terminal. It is a container for Stream objects. A line’s width is determined by the Geometry::Geometry it belongs to.
Instance Attribute Summary collapse
Attributes included from Model
Instance Method Summary collapse
- #add(child) ⇒ Vedeu::Views::Stream (also: #<<)
-
#chars ⇒ Array
Returns an array of all the characters with formatting for this line.
-
#defaults ⇒ Hash
private
The default values for a new instance of this class.
-
#eql?(other) ⇒ Boolean
(also: #==)
An object is equal when its values are the same.
-
#initialize(attributes = {}) ⇒ Vedeu::Views::Line
constructor
Returns a new instance of Vedeu::Views::Line.
-
#size ⇒ Fixnum
Returns the size of the content in characters without formatting.
- #value ⇒ Vedeu::Views::Streams (also: #streams)
Methods included from Presentation
#render_colour, #render_position, #render_style, #to_s
Methods included from Presentation::Styles
Methods included from Presentation::Colour
#background, #background=, #colour, #colour=, #foreground, #foreground=
Methods included from Model
#deputy, #dsl_class, included, #store
Methods included from Common
#demodulize, #present?, #snake_case
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Views::Line
Returns a new instance of Vedeu::Views::Line.
33 34 35 36 37 38 39 |
# File 'lib/vedeu/models/views/line.rb', line 33 def initialize(attributes = {}) @attributes = defaults.merge!(attributes) @attributes.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#attributes ⇒ Hash (readonly)
19 20 21 |
# File 'lib/vedeu/models/views/line.rb', line 19 def attributes @attributes end |
#parent ⇒ Vedeu::Views::View
23 24 25 |
# File 'lib/vedeu/models/views/line.rb', line 23 def parent @parent end |
Instance Method Details
#add(child) ⇒ Vedeu::Views::Stream Also known as: <<
43 44 45 |
# File 'lib/vedeu/models/views/line.rb', line 43 def add(child) @value = value.add(child) end |
#chars ⇒ Array
Returns an array of all the characters with formatting for this line.
52 53 54 55 56 |
# File 'lib/vedeu/models/views/line.rb', line 52 def chars return [] if value.empty? @chars ||= value.flat_map(&:chars) end |
#defaults ⇒ Hash (private)
The default values for a new instance of this class.
85 86 87 88 89 90 91 92 93 |
# File 'lib/vedeu/models/views/line.rb', line 85 def defaults { client: nil, colour: nil, parent: nil, style: nil, value: [], } end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
62 63 64 |
# File 'lib/vedeu/models/views/line.rb', line 62 def eql?(other) self.class == other.class && value == other.value end |
#size ⇒ Fixnum
Returns the size of the content in characters without formatting.
70 71 72 |
# File 'lib/vedeu/models/views/line.rb', line 70 def size value.map(&:size).inject(0, :+) end |
#value ⇒ Vedeu::Views::Streams Also known as: streams
75 76 77 |
# File 'lib/vedeu/models/views/line.rb', line 75 def value collection.coerce(@value, self) end |