Class: Logaling::Command::Renderers::TermDefaultRenderer
Instance Method Summary
collapse
#source_term, #target_term
Constructor Details
#initialize(term, repository, config, options) ⇒ TermDefaultRenderer
Returns a new instance of TermDefaultRenderer.
66
67
68
69
70
71
72
73
|
# File 'lib/logaling/command/renderers.rb', line 66
def initialize(term, repository, config, options)
super
@term[:snipped_source_term] = [@term[:source_term]]
@term[:snipped_target_term] = [@term[:target_term]]
@render_option = {}
@render_option[:show_glossary] = true
@max_source_term_width = 0
end
|
Instance Method Details
#glossary_name ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/logaling/command/renderers.rb', line 80
def glossary_name
if @render_option[:show_glossary] && @repository.glossary_counts > 1
if @term[:glossary_name] == @config.glossary
@term[:glossary_name].foreground(:white).background(:green)
else
@term[:glossary_name]
end
else
""
end
end
|
#hide_glossary_name ⇒ Object
101
102
103
|
# File 'lib/logaling/command/renderers.rb', line 101
def hide_glossary_name
@render_option[:show_glossary] = false
end
|
#note ⇒ Object
92
93
94
95
|
# File 'lib/logaling/command/renderers.rb', line 92
def note
note_string = super
"# #{note_string}" if note_string
end
|
#padded_source_term ⇒ Object
97
98
99
|
# File 'lib/logaling/command/renderers.rb', line 97
def padded_source_term
source_term + " " * padding_size(@term[:source_term], @max_source_term_width)
end
|
#render(output) ⇒ Object
75
76
77
78
|
# File 'lib/logaling/command/renderers.rb', line 75
def render(output)
formatted_text = [padded_source_term, target_term, note, glossary_name].compact.join("\t")
output.printf(" %s\n", formatted_text)
end
|
#set_max_source_term_width(terms) ⇒ Object
105
106
107
|
# File 'lib/logaling/command/renderers.rb', line 105
def set_max_source_term_width(terms)
@max_source_term_width = terms.map{|term| string_display_width(term[:source_term]) }.max
end
|