Module: Hirb
- Defined in:
- lib/hirb.rb,
lib/hirb/menu.rb,
lib/hirb/util.rb,
lib/hirb/view.rb,
lib/hirb/pager.rb,
lib/hirb/string.rb,
lib/hirb/console.rb,
lib/hirb/helpers.rb,
lib/hirb/formatter.rb,
lib/hirb/helpers/table.rb,
lib/hirb/import_object.rb
Overview
Base Table class from which other table classes inherit. By default, a table is constrained to a default width but this can be adjusted via the max_width option or Hirb::View.width. Rows can be an array of arrays or an array of hashes.
An array of arrays ie [[1,2], [2,3]], would render:
+---+---+
| 0 | 1 |
+---+---+
| 1 | 2 |
| 2 | 3 |
+---+---+
By default, the fields/columns are the numerical indices of the array.
An array of hashes ie [:weight=>100, :weight=>500], would render:
+-----+--------+
| age | weight |
+-----+--------+
| 10 | 100 |
| 80 | 500 |
+-----+--------+
By default, the fields/columns are the keys of the first hash.
derived from http://gist.github.com/72234
Defined Under Namespace
Modules: Console, Helpers, ObjectMethods, String, Util, View, Views Classes: Formatter, HashStruct, Menu, Pager
Class Method Summary collapse
- .config(reload = false) ⇒ Object
-
.config_file ⇒ Object
Default is config/hirb.yml or ~/hirb.yml in that order.
-
.config_file=(value) ⇒ Object
:stopdoc:.
-
.disable ⇒ Object
Disables view functionality.
-
.enable(options = {}, &block) ⇒ Object
Enables view functionality.
- .read_config_file(file = config_file) ⇒ Object
Class Method Details
.config(reload = false) ⇒ Object
57 58 59 |
# File 'lib/hirb.rb', line 57 def config(reload=false) @config = (@config.nil? || reload) ? read_config_file : @config end |
.config_file ⇒ Object
Default is config/hirb.yml or ~/hirb.yml in that order.
43 44 45 46 |
# File 'lib/hirb.rb', line 43 def config_file @config_file ||= File.exists?('config/hirb.yml') ? 'config/hirb.yml' : File.(File.join(ENV["HOME"] || ".", ".hirb.yml")) end |
.config_file=(value) ⇒ Object
:stopdoc:
49 50 51 |
# File 'lib/hirb.rb', line 49 def config_file=(value) @config_file = value end |
.disable ⇒ Object
Disables view functionality. See Hirb::View.disable for details.
39 40 41 |
# File 'lib/hirb.rb', line 39 def disable View.disable end |
.enable(options = {}, &block) ⇒ Object
Enables view functionality. See Hirb::View.enable for details.
34 35 36 |
# File 'lib/hirb.rb', line 34 def enable(={}, &block) View.enable(, &block) end |
.read_config_file(file = config_file) ⇒ Object
53 54 55 |
# File 'lib/hirb.rb', line 53 def read_config_file(file=config_file) File.exists?(file) ? YAML::load_file(file) : {} end |