error aligning by default? #21

Closed
klepsydra opened this Issue Mar 26, 2012 · 2 comments

Comments

Projects
None yet
2 participants

I am trying to align all my tables :right by default, since they deal mostly with numbers (integer and float).

Terminal::Style.defaults = {:alignment => :right} # fails with: uninitialized constant Terminal::Style

sttab = Terminal::Table.new :alignment => :right #NoMethodError: undefined method `alignment=' for #Terminal::Table::Style:0x8fe858c

Terminal::Table::Style.defaults = {:alignment => :right} # silently accepts, but later at new or initialize gives NoMethodError: undefined method `alignment=' for #Terminal::Table::Style:0x8498f38

ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

terminal-table (1.4.5)

Collaborator

scottjg commented Apr 1, 2012

it looks like the current code only allows defining alignment per-column or per-cell. it's not a style option, so there's no way to set a default. making alignment into a style option seems like it might be reasonable at first glance. i'll look into it (patches welcome, of course).

I'm not sure how to patch but at the moment I use in my code to align all
columns:

(1..sttab2.columns.size).each {|c| sttab2.align_column(c-1, :right) }

On Sun, Apr 1, 2012 at 02:40, Scott J. Goldman <
reply@reply.github.com

wrote:

it looks like the current code only allows defining alignment per-column
or per-cell. it's not a style option, so there's no way to set a default.
making alignment into a style option seems like it might be reasonable at
first glance. i'll look into it (patches welcome, of course).


Reply to this email directly or view it on GitHub:

visionmedia#21 (comment)

scottjg closed this in 8f67731 May 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment