Top Level Namespace
Defined Under Namespace
Modules: Arbi, TimeLine, Wireless Classes: Float, Integer, Numeric, Rational
Instance Method Summary collapse
- #load_module(file) ⇒ Object
-
#tablize(args) ⇒ Object
– Copyleft shura.
Instance Method Details
#load_module(file) ⇒ Object
160 161 162 163 164 165 166 167 168 |
# File 'lib/arbi/modules.rb', line 160 def load_module(file) lp = $:.dup $:.replace(Arbi::Config[:modules][:path] + $:) require file rescue Exception => e Arbi.debug("Error loading module: #{e}") ensure $:.replace(lp) end |
#tablize(args) ⇒ Object
– Copyleft shura. [ [email protected] ]
This file is part of arbi.
arbi is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
arbi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with arbi. If not, see <www.gnu.org/licenses/>. ++
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/arbi/utils/table.rb', line 20 def tablize(args) lens, res, div = [], "", "" args.each {|row| row.each_with_index {|e, i| lens[i] ||= 0 lens[i] = [lens[i], e.to_s.length].max } } div = ?+ + lens.map {|s| (?- * s) + ?+ }.join res += div + "\n" args.each_with_index {|row, index| res += ?| row.each_with_index {|e, i| res += (e || ?-).to_s.center(lens[i]) + ?| } res += "\n" + div if index == 0 res += "\n" } res += div + "\n" end |