lib/translate.rb
# Only used when translate is called from command line.
# Print results in the shell.
Only used when translate is called from command line.
Print results in the shell.
Only used when translate is called from command line . Print results in the shell .
def print
			lambda { puts "No results found." ; exit }.call if @items.empty?
			half = (width - 4) / 2 
			puts @items.inject("") { |o, item|
				str  = item == @items.first ? "#{separator}\n#{@expression.center(width, ' ')}\n" : ""
				str  += "#{separator}\n" if item.new_line
				str  += " %-#{half}s|"		% item.description.truncate(half)
				str  += " %-#{half}s\n"  % item.translation.truncate(half)
				str  += "#{separator}\n" if item == @items.last
				o + str
			}
		end
def print lambda { puts "No results found." ; exit } . call if @items . empty? half = ( width - 4 ) / 2 puts @items . inject ( "" ) { | o , item | str = item == @items . first ? "#{separator}\n#{@expression.center(width, ' ')}\n" : "" str += "#{separator}\n" if item . new_line str += " %-#{half}s|" % item . description . truncate ( half ) str += " %-#{half}s\n" % item . translation . truncate ( half ) str += "#{separator}\n" if item == @items . last o + str } end
Only used when translate is called from command line.
Only used when translate is called from command line .
# 4 : 2 slash and space