class Flagdoc::Stream
Display parsed flags informations
@since 0.1.0
Constants
- BOX_SIZE
- COLORS
- LINE_SIZE
- TAB_SIZE
Public Class Methods
new(store:)
click to toggle source
@since 1.0.1
# File lib/flagdoc/stream.rb, line 17 def initialize(store:) @store = store end
Public Instance Methods
call()
click to toggle source
Launch the stream of stored informations
@since 1.0.1
@return [STDOUT] with formatted informations
# File lib/flagdoc/stream.rb, line 26 def call @store.files.each do |file| file_path(file[:path]) flags(file[:flags]) end end
Private Instance Methods
blank()
click to toggle source
# File lib/flagdoc/stream.rb, line 76 def blank blank = colorize(description_color, space_line(BOX_SIZE)) puts "#{tab}#{blank}" end
colorize(color, content)
click to toggle source
# File lib/flagdoc/stream.rb, line 103 def colorize(color, content) format( "\e[%<color>sm %<content>s \e[0m", color: color, content: content ) end
content(description)
click to toggle source
# File lib/flagdoc/stream.rb, line 83 def content(description) space_description = space_line(BOX_SIZE - description.length) description_content = colorize( description_color, description.capitalize + space_description ) puts "#{tab}#{description_content}" end
file_path(path)
click to toggle source
@return [STDOUT] colored file path
# File lib/flagdoc/stream.rb, line 50 def file_path(path) puts puts "\e[#{file_color}m#{path}\e[0m" puts end
flags(flags)
click to toggle source
@return [STDOUT] colored flags
# File lib/flagdoc/stream.rb, line 57 def flags(flags) flags.each do |flag| head(flag[:type], "line #{flag[:line]}", flag[:priority]) blank content(flag[:description]) blank puts end end
head(type, line, priority)
click to toggle source
# File lib/flagdoc/stream.rb, line 67 def head(type, line, priority) space_line = space_line(LINE_SIZE - line.length) space_type = space_line((BOX_SIZE - LINE_SIZE - 2) - type.length) line_content = colorize(line_color, space_line + line) type_content = colorize(type_color(priority), type + space_type) puts "#{tab}#{type_content}#{line_content}" end
space_line(number)
click to toggle source
# File lib/flagdoc/stream.rb, line 95 def space_line(number) ' ' * number end
tab(number = 1)
click to toggle source
# File lib/flagdoc/stream.rb, line 99 def tab(number = 1) space_line(TAB_SIZE * number) end
type_color(priority)
click to toggle source
# File lib/flagdoc/stream.rb, line 45 def type_color(priority) "1;97;#{Priority.color_code(priority)}" end