Class: Vedeu::Output::Write Private

Inherits:
Object
  • Object
show all
Includes:
Presentation, Presentation::Colour, Presentation::Position, Presentation::Styles
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

#render_style, #style, #style=, #style?

Methods included from Presentation::Parent

#name, #parent?

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=, #interface, #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



37
38
39
40
41
42
# File 'lib/vedeu/output/write.rb', line 37

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)


65
66
67
# File 'lib/vedeu/output/write.rb', line 65

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


24
25
26
# File 'lib/vedeu/output/write.rb', line 24

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


71
72
73
74
75
76
# File 'lib/vedeu/output/write.rb', line 71

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


79
80
81
# File 'lib/vedeu/output/write.rb', line 79

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)


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

def parent
  nil
end

#position(pos = position_start) ⇒ NilClass|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.

Returns:



50
51
52
# File 'lib/vedeu/output/write.rb', line 50

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


98
99
100
101
102
103
# File 'lib/vedeu/output/write.rb', line 98

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


90
91
92
93
94
95
# File 'lib/vedeu/output/write.rb', line 90

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)


106
107
108
# File 'lib/vedeu/output/write.rb', line 106

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)


66
67
68
# File 'lib/vedeu/output/write.rb', line 66

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


55
56
57
58
59
# File 'lib/vedeu/output/write.rb', line 55

def write
  Vedeu.direct_write(to_s)

  to_s
end