Class: Vedeu::Output::Direct

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/output/direct.rb

Overview

Write a string directly to the terminal at defined coordinates.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, x:, y:) ⇒ Vedeu::Output::Direct

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

Parameters:

  • value (String)
  • x (Fixnum)
  • y (Fixnum)


23
24
25
26
27
# File 'lib/vedeu/output/direct.rb', line 23

def initialize(value:, x:, y:)
  @value = value || ''
  @x     = x     || 1
  @y     = y     || 1
end

Instance Attribute Details

#valueString (readonly, protected)

Returns:

  • (String)


40
41
42
# File 'lib/vedeu/output/direct.rb', line 40

def value
  @value
end

#xFixnum (readonly, protected)

Returns:

  • (Fixnum)


44
45
46
# File 'lib/vedeu/output/direct.rb', line 44

def x
  @x
end

#yFixnum (readonly, protected)

Returns:

  • (Fixnum)


48
49
50
# File 'lib/vedeu/output/direct.rb', line 48

def y
  @y
end

Class Method Details

.write(value:, x:, y:) ⇒ String

Parameters:

  • value (String)
  • x (Fixnum)
  • y (Fixnum)

Returns:

  • (String)


13
14
15
# File 'lib/vedeu/output/direct.rb', line 13

def self.write(value:, x:, y:)
  new(value: value, x: x, y: y).write
end

Instance Method Details

#outputString (private)

Returns:

  • (String)


53
54
55
# File 'lib/vedeu/output/direct.rb', line 53

def output
  (Array(position) + Array(value)).join
end

#positionString (private)

Returns:

  • (String)


58
59
60
# File 'lib/vedeu/output/direct.rb', line 58

def position
  Vedeu::Geometry::Position.new(y, x).to_s
end

#writeString

Returns:

  • (String)


30
31
32
33
34
# File 'lib/vedeu/output/direct.rb', line 30

def write
  Vedeu::Terminal.output(output)

  output
end