Class: Vedeu::Output::Write Private

Inherits:
Object
  • Object
show all
Includes:
Presentation
Defined in:
lib/vedeu/output/write.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Directly write to the terminal.

Examples:

Vedeu.write(output, options)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = nil, options = {}) ⇒ Vedeu::Output::Write

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Vedeu::Output::Write.

Parameters:

  • output (String) (defaults to: nil)
  • options (Hash<Symbol => Fixnum>) (defaults to: {})
  • x (Hash)

    a customizable set of options

  • y (Hash)

    a customizable set of options

  • colour (Hash)

    a customizable set of options

  • style (Hash)

    a customizable set of options



33
34
35
36
37
38
# File 'lib/vedeu/output/write.rb', line 33

def initialize(output = nil, options = {})
  @output  = output
  @options = options
  @colour  = options[:colour]
  @style   = options[:style]
end

Instance Attribute Details

#outputString (readonly, private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


61
62
63
# File 'lib/vedeu/output/write.rb', line 61

def output
  @output
end

Class Method Details

.write(output = nil, options = {}) ⇒ Object

See Also:



20
21
22
# File 'lib/vedeu/output/write.rb', line 20

def self.write(output = nil, options = {})
  new(output, options).write
end

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#backgroundVedeu::Colours::Background Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.

#background=(value) ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.

#become(klass, attributes) ⇒ Class Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts one class into another.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

#boolean(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating the value was a boolean.

Parameters:

  • value (void)

Returns:

#boolean?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value is a Boolean.

Parameters:

Returns:

#colourVedeu::Colours::Colour Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.

#colour?Boolean Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

#defaultsHash<Symbol => Fixnum> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash<Symbol => Fixnum>)


67
68
69
70
71
72
# File 'lib/vedeu/output/write.rb', line 67

def defaults
  {
    x: 1,
    y: 1,
  }
end

#escape?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)

Returns:

#falsy?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value should be considered false.

Parameters:

  • value (void)

Returns:

#foregroundVedeu::Colours::Foreground Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.

#foreground=(value) ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.

#hash?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value is a Hash.

Parameters:

  • value (Hash|void)

Returns:

#line_model?Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating the model is a Views::Line.

Returns:

#nameNilClass|String|Symbol Originally defined in module Presentation::Styles

Returns:

  • (NilClass|String|Symbol)

#named_colourVedeu::Colours::Colour (private) Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

#named_colour?Boolean (private) Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

#numeric?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value is a Fixnum.

Parameters:

  • value (Fixnum|void)

Returns:

#optionsHash<Symbol => Fixnum> (private) Also known as: attributes

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash<Symbol => Fixnum>)


75
76
77
# File 'lib/vedeu/output/write.rb', line 75

def options
  defaults.merge!(@options)
end

#parentNilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (NilClass)


41
42
43
# File 'lib/vedeu/output/write.rb', line 41

def parent
  nil
end

#parent_colourVedeu::Colours::Colour (private) Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

#parent_colour?Boolean (private) Originally defined in module Presentation::Colour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

#position(pos = position_start) ⇒ Vedeu::Geometries::Position

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/vedeu/output/write.rb', line 46

def position(pos = position_start)
  Vedeu::Geometries::Position.coerce(pos)
end

#position=(value) ⇒ Vedeu::Geometries::Position Originally defined in module Presentation::Position

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets the position.

Parameters:

Returns:

#position?Boolean Originally defined in module Presentation::Position

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating the position attribute of the including model is set.

Returns:

#position_endHash<Symbol => Fixnum> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash<Symbol => Fixnum>)


94
95
96
97
98
99
# File 'lib/vedeu/output/write.rb', line 94

def position_end
  {
    x: options[:x] + output.size,
    y: options[:y],
  }
end

#position_startHash<Symbol => Fixnum> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash<Symbol => Fixnum>)


86
87
88
89
90
91
# File 'lib/vedeu/output/write.rb', line 86

def position_start
  {
    x: options[:x],
    y: options[:y],
  }
end

#present?(variable) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#render_colour(&block) ⇒ String (private) Originally defined in module Presentation

Renders the colour attributes of the receiver and yields (to then render the styles).

Parameters:

  • block (Proc)

Returns:

  • (String)

#render_position(&block) ⇒ String (private) Originally defined in module Presentation

Parameters:

  • block (Proc)

Returns:

  • (String)

#render_style(&block) ⇒ String (private) Originally defined in module Presentation

Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).

Parameters:

  • block (Proc)

Returns:

  • (String)

#snake_case(klass) ⇒ String Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

snake_case('MyClassName') # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • klass (Module|Class|String)

Returns:

  • (String)

#stream_model?Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating the model is a Views::Stream.

Returns:

#string?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value is a Fixnum.

Parameters:

  • value (String|void)

Returns:

#styleVedeu::Presentation::Style Originally defined in module Presentation::Styles

When the style for the model exists, return it, otherwise returns the parent style, or an empty Vedeu::Presentation::Style.

#style=(value) ⇒ Vedeu::Presentation::Style Originally defined in module Presentation::Styles

Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.

#to_sString (private) Also known as: to_str

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


102
103
104
# File 'lib/vedeu/output/write.rb', line 102

def to_s
  @_to_s ||= super + Vedeu.esc.reset + position(position_end)
end

#truthy?(value) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the value should be considered true.

Parameters:

  • value (void)

Returns:

#valueString (protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


62
63
64
# File 'lib/vedeu/output/write.rb', line 62

def output
  @output
end

#view_model?Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating the model is a Views::View.

Returns:

#writeArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<String>)


51
52
53
54
55
# File 'lib/vedeu/output/write.rb', line 51

def write
  Vedeu.direct_write(to_s)

  to_s
end

#xFixnum|NilClass Originally defined in module Presentation::Position

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the x coordinate for the model when the position attribute of the including model is set.

Returns:

  • (Fixnum|NilClass)

#yFixnum|NilClass Originally defined in module Presentation::Position

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the y coordinate for the model when the position attribute of the including model is set.

Returns:

  • (Fixnum|NilClass)