Class: Vedeu::Line
- Inherits:
-
Object
- Object
- Vedeu::Line
- Includes:
- Model, Presentation
- Defined in:
- lib/vedeu/models/view/line.rb
Overview
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
- #streams ⇒ Vedeu::Streams
Attributes included from Model
Instance Method Summary collapse
- #add(child) ⇒ void
-
#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.
-
#empty? ⇒ Boolean
Returns a boolean indicating whether the line has content.
-
#initialize(attributes = {}) ⇒ Vedeu::Line
constructor
Returns a new instance of Line.
-
#size ⇒ Fixnum
Returns the size of the content in characters without formatting.
-
#value ⇒ Object
Returns the value of attribute streams.
-
#width ⇒ Fixnum
Delegate to Vedeu::Interface#width if available.
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
Methods included from Model
#demodulize, #deputy, #dsl_class, included, #store
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Line
Returns a new instance of Line.
32 33 34 35 36 37 38 |
# File 'lib/vedeu/models/view/line.rb', line 32 def initialize(attributes = {}) @attributes = defaults.merge!(attributes) @colour = @attributes[:colour] @parent = @attributes[:parent] @streams = @attributes[:streams] @style = @attributes[:style] end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
19 20 21 |
# File 'lib/vedeu/models/view/line.rb', line 19 def parent @parent end |
#streams ⇒ Vedeu::Streams
71 72 73 |
# File 'lib/vedeu/models/view/line.rb', line 71 def streams @streams end |
Instance Method Details
#add(child) ⇒ void
This method returns an undefined value.
42 43 44 |
# File 'lib/vedeu/models/view/line.rb', line 42 def add(child) @streams = streams.add(child) end |
#chars ⇒ Array
Returns an array of all the characters with formatting for this line.
50 51 52 53 54 |
# File 'lib/vedeu/models/view/line.rb', line 50 def chars return [] if empty? streams.map(&:chars).flatten end |
#defaults ⇒ Hash (private)
The default values for a new instance of this class.
87 88 89 90 91 92 93 94 95 |
# File 'lib/vedeu/models/view/line.rb', line 87 def defaults { client: nil, colour: nil, parent: nil, streams: [], style: nil, } end |
#empty? ⇒ Boolean
Returns a boolean indicating whether the line has content.
59 60 61 |
# File 'lib/vedeu/models/view/line.rb', line 59 def empty? streams.empty? end |
#size ⇒ Fixnum
Returns the size of the content in characters without formatting.
66 67 68 |
# File 'lib/vedeu/models/view/line.rb', line 66 def size streams.map(&:size).inject(0, :+) { |sum, x| sum += x } end |
#value ⇒ Object
Returns the value of attribute streams.
22 23 24 |
# File 'lib/vedeu/models/view/line.rb', line 22 def streams @streams end |
#width ⇒ Fixnum
Delegate to Vedeu::Interface#width if available.
78 79 80 |
# File 'lib/vedeu/models/view/line.rb', line 78 def width parent.width if parent end |