Class: Vedeu::Views::Line
- Inherits:
-
Object
- Object
- Vedeu::Views::Line
- Extended by:
- Forwardable
- Includes:
- Presentation, Repositories::Model, DefaultAttributes, Value
- Defined in:
- lib/vedeu/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 Geometries::Geometry it belongs to.
Defined Under Namespace
Classes: DSL
Instance Attribute Summary
Attributes included from Repositories::Model
Attributes included from DefaultAttributes
#align, #pad, #truncate, #width, #wordwrap
Instance Method Summary collapse
-
#add(child) ⇒ Vedeu::Views::Stream
(also: #<<)
Adds the child to the collection.
-
#chars ⇒ Array
Returns an array of all the characters with formatting for this line.
-
#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.
- #name ⇒ NilClass|String|Symbol
- #parent ⇒ NilClass|void
-
#size ⇒ Fixnum
Returns the size of the content in characters without formatting.
Methods included from Value
Methods included from Presentation
Methods included from Presentation::Styles
#render_style, #style, #style=
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Methods included from Presentation::Position
#position, #position=, #position?, #render_position, #x, #y
Methods included from Presentation::Colour
#background, #background=, #colour, #colour=, #colour?, #foreground, #foreground=, #named_colour, #named_colour?, #parent_colour, #parent_colour?, #render_colour
Methods included from Repositories::Model
Methods included from DefaultAttributes
Methods included from Repositories::Defaults
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Views::Line
Returns a new instance of Vedeu::Views::Line.
53 54 55 56 57 |
# File 'lib/vedeu/views/line.rb', line 53 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Method Details
#add(child) ⇒ Vedeu::Views::Stream Also known as: <<
Adds the child to the collection.
63 64 65 |
# File 'lib/vedeu/views/line.rb', line 63 def add(child) @value = value.add(child) end |
#chars ⇒ Array
Returns an array of all the characters with formatting for this line.
73 74 75 76 77 |
# File 'lib/vedeu/views/line.rb', line 73 def chars return [] unless streams? @chars ||= streams.flat_map(&:chars) end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
83 84 85 |
# File 'lib/vedeu/views/line.rb', line 83 def eql?(other) self.class.equal?(other.class) && value == other.value end |
#name ⇒ NilClass|String|Symbol
89 90 91 92 93 94 95 96 97 |
# File 'lib/vedeu/views/line.rb', line 89 def name if present?(@name) @name elsif parent && present?(parent.name) parent.name end end |
#parent ⇒ NilClass|void
100 101 102 |
# File 'lib/vedeu/views/line.rb', line 100 def parent present?(@parent) ? @parent : nil end |
#size ⇒ Fixnum
Returns the size of the content in characters without formatting.
108 109 110 |
# File 'lib/vedeu/views/line.rb', line 108 def size streams.map(&:size).inject(0, :+) end |