Class: Andrewmcodes::Output

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

Instance Method Summary collapse

Instance Method Details

#ascii(a_string) ⇒ Object



29
30
31
32
33
# File 'lib/andrewmcodes/output.rb', line 29

def ascii(a_string)
  a = Artii::Base.new font: "slant"
  out = a.asciify(a_string)
  system("echo '#{out}' | lolcat")
end

#centered_message(message) ⇒ Object



52
53
54
55
# File 'lib/andrewmcodes/output.rb', line 52

def centered_message(message)
  content = Center.new(output: message, columns: terminal_width)
  content.centered_content
end

#echo(message) ⇒ Object



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

def echo(message)
  system("echo '#{centered_message(message)}'")
end

#log_infoObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/andrewmcodes/output.rb', line 35

def log_info
  templates_root = File.expand_path(File.join(".", "."), File.dirname(__FILE__))
  content = File.readlines "#{templates_root}/info.md"

  File.open("./../../temp.md", "w") do |_file|
    content.each do |line|
      system("echo '#{centered_message(line)}' | lolcat")
    end
  end

  FileUtils.rm("./../../temp.md")
end

#log_to_consoleObject

delegate :centered_message, to: :center



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/andrewmcodes/output.rb', line 10

def log_to_console
  if terminal_width >= 83
    # content = Center.new(terminal_width-83, terminal_width)
    spces = Center.new(output: 83, columns: terminal_width)
    move_over = spces.spaces(100)
    ascii("#{move_over}andrewmcodes")

    p
  else
    echo("\nAndrew Mason \/ andrewmcodes\n")
  end

  log_info
end

#terminal_widthObject



25
26
27
# File 'lib/andrewmcodes/output.rb', line 25

def terminal_width
  @terminal_width ||= `tput cols`.strip.to_i
end