Class: Vedeu::Views::Stream

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Presentation, Repositories::Model, DefaultAttributes, Value
Defined in:
lib/vedeu/views/stream.rb

Overview

Represents a character or collection of characters as part of a Line which you wish to colour and style independently of the other characters in that line.

Defined Under Namespace

Classes: DSL

Instance Attribute Summary collapse

Attributes included from Repositories::Model

#repository

Attributes included from DefaultAttributes

#align, #pad, #truncate, #width, #wordwrap

Instance Method Summary collapse

Methods included from Value

included

Methods included from Presentation

#to_s

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

included, #store

Methods included from DefaultAttributes

#attributes, #defaults

Methods included from Repositories::Defaults

#defaults, #validate

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Views::Stream

Returns a new instance of Vedeu::Views::Stream.

Parameters:

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

Options Hash (attributes):



61
62
63
64
65
# File 'lib/vedeu/views/stream.rb', line 61

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

Instance Attribute Details

#value=(value) ⇒ String (writeonly) Also known as: chars=

Returns:

  • (String)


49
50
51
# File 'lib/vedeu/views/stream.rb', line 49

def value=(value)
  @value = value
end

Instance Method Details

#add(child) ⇒ Vedeu::Views::Streams Also known as: <<

Adds the child to the collection.

Parameters:

Returns:



71
72
73
74
75
76
77
78
79
80
# File 'lib/vedeu/views/stream.rb', line 71

def add(child)
  if defined?(parent) && present?(parent)
    parent.add(child)

  else
    @value = child

    self
  end
end

#eql?(other) ⇒ Boolean Also known as: ==

An object is equal when its values are the same.

Parameters:

  • other (void)

Returns:



87
88
89
# File 'lib/vedeu/views/stream.rb', line 87

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

#nameNilClass|String|Symbol

Returns:

  • (NilClass|String|Symbol)


93
94
95
96
97
98
99
100
101
# File 'lib/vedeu/views/stream.rb', line 93

def name
  if present?(@name)
    @name

  elsif parent && present?(parent.name)
    parent.name

  end
end

#parentNilClass|void

Returns:

  • (NilClass|void)


104
105
106
# File 'lib/vedeu/views/stream.rb', line 104

def parent
  present?(@parent) ? @parent : nil
end