Class: Latex::Formatters::IntegerFormatter
- Inherits:
-
Object
- Object
- Latex::Formatters::IntegerFormatter
- Defined in:
- lib/ruby-latex.rb
Instance Method Summary collapse
- #call(object) ⇒ Object
-
#initialize(comma = true, nums = nil) ⇒ IntegerFormatter
constructor
A new instance of IntegerFormatter.
Constructor Details
#initialize(comma = true, nums = nil) ⇒ IntegerFormatter
Returns a new instance of IntegerFormatter.
375 376 377 378 |
# File 'lib/ruby-latex.rb', line 375 def initialize(comma=true, nums=nil) @format = "%#{nums}d" @comma = comma end |
Instance Method Details
#call(object) ⇒ Object
380 381 382 383 384 |
# File 'lib/ruby-latex.rb', line 380 def call(object) result = @format % [object.to_i] result = result.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,") if @comma return result end |