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

Methods included from Presentation::Styles

#name, #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?, #render_position, #x, #y

Methods included from Presentation::Colour

#background, #background=, #colour, #colour=, #colour?, #foreground, #foreground=, #name, #named_colour, #named_colour?, #parent_colour, #parent_colour?, #render_colour

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



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

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)


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

def output
  @output
end

Class Method Details

.write(output = nil, options = {}) ⇒ Array<String>

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

Returns:

  • (Array<String>)


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

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

Instance Method Details

#defaultsHash<Symbol => void> (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.

The default options/attributes for a new instance of this class.

Returns:

  • (Hash<Symbol => void>)


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

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

#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>)


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

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)


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

def parent
  nil
end

#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.



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

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

#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>)


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

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>)


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

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

#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)


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

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

#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)


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

def output
  @output
end

#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>)


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

def write
  Vedeu.direct_write(to_s)

  to_s
end