Class: Scripted::Formatters::Table::Column
- Inherits:
-
Object
- Object
- Scripted::Formatters::Table::Column
- Defined in:
- lib/scripted/formatters/table.rb
Instance Attribute Summary collapse
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #aligned(width) ⇒ Object
-
#initialize(value, suffix) ⇒ Column
constructor
A new instance of Column.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value, suffix) ⇒ Column
Returns a new instance of Column.
60 61 62 |
# File 'lib/scripted/formatters/table.rb', line 60 def initialize(value, suffix) @value, @suffix = value, suffix end |
Instance Attribute Details
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
54 55 56 |
# File 'lib/scripted/formatters/table.rb', line 54 def suffix @suffix end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
54 55 56 |
# File 'lib/scripted/formatters/table.rb', line 54 def value @value end |
Class Method Details
.[](value, suffix = "") ⇒ Object
56 57 58 |
# File 'lib/scripted/formatters/table.rb', line 56 def self.[](value, suffix = "") new(value, suffix) end |
Instance Method Details
#aligned(width) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/scripted/formatters/table.rb', line 86 def aligned(width) case value when Numeric to_s.rjust(width) else to_s.ljust(width) end end |
#size ⇒ Object
82 83 84 |
# File 'lib/scripted/formatters/table.rb', line 82 def size to_s.size end |
#to_s ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/scripted/formatters/table.rb', line 64 def to_s string = case value when Fixnum value.to_s when Numeric "%.3f" % value when NilClass nil else value.to_s end if string "#{string}#{suffix}" else "" end end |