Class: Budik::IO

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/budik/io.rb

Overview

‘Output’ class provides information to the user via console.

Instance Method Summary collapse

Constructor Details

#initializeIO

Loads output strings in currently set language.



16
17
18
# File 'lib/budik/io.rb', line 16

def initialize
  @strings = Config.instance.lang.output
end

Instance Method Details

#run_info_table(source, number) ⇒ Object

Outputs table formatted information about selected source to the console.

  • Args:

    • source -> Selected source (Hash).

    • number -> Number of selected source (Fixnum).



27
28
29
30
31
32
33
34
35
36
# File 'lib/budik/io.rb', line 27

def run_info_table(source, number)
  title = 'Budik - ' + DateTime.now.strftime('%d/%m/%Y %H:%M')

  rows = []
  rows << [@strings.alarm, source[:name]]
  rows << [@strings.category, source[:category].to_s]
  rows << [@strings.number, number.to_s]

  Terminal::Table.new title: title, rows: rows
end

#sources_print(sources) ⇒ Object

Outputs formatted list of sources to the console.

  • Args:

    • sources -> Parsed sources (Array of Hashes).



43
44
45
46
47
# File 'lib/budik/io.rb', line 43

def sources_print(sources)
  sources.each_with_index do |source, index|
    puts '[' + index.to_s.light_white + '] ' + source[:name].yellow
  end
end

#storage_download_info(source) ⇒ Object

Outputs information about source being downloaded.

  • Args:

    • source -> Source being downloaded (Hash).



54
55
56
# File 'lib/budik/io.rb', line 54

def storage_download_info(source)
  puts @strings.downloading + source[:name]
end