Class: TabularText::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/tabular-text/field.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, length = nil) ⇒ Field

Returns a new instance of Field.



5
6
7
8
# File 'lib/tabular-text/field.rb', line 5

def initialize(content, length = nil)
  @content = content
  @length = length
end

Instance Method Details

#lengthObject



10
11
12
# File 'lib/tabular-text/field.rb', line 10

def length
  @length || @content.to_s.length
end

#to_sObject



14
15
16
# File 'lib/tabular-text/field.rb', line 14

def to_s
  ActiveSupport::Inflector.transliterate(pad).encode('ASCII')
end