class Puppet::Pops::Time::Timespan::Format::ValueSegment
Public Class Methods
new(padchar, width, default_width)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 355 def initialize(padchar, width, default_width) 356 @use_total = false 357 @padchar = padchar 358 @width = width 359 @default_width = default_width 360 @format = create_format 361 end
Public Instance Methods
append_regexp(bld)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 374 def append_regexp(bld) 375 if @width.nil? 376 case @padchar 377 when nil 378 bld << (use_total? ? '([0-9]+)' : "([0-9]{1,#{@default_width}})") 379 when '0' 380 bld << (use_total? ? '([0-9]+)' : "([0-9]{1,#{@default_width}})") 381 else 382 bld << (use_total? ? '\s*([0-9]+)' : "([0-9\\s]{1,#{@default_width}})") 383 end 384 else 385 case @padchar 386 when nil 387 bld << "([0-9]{1,#{@width}})" 388 when '0' 389 bld << "([0-9]{#{@width}})" 390 else 391 bld << "([0-9\\s]{#{@width}})" 392 end 393 end 394 end
append_value(bld, n)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 412 def append_value(bld, n) 413 bld << sprintf(@format, n) 414 end
create_format()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 363 def create_format 364 case @padchar 365 when nil 366 '%d' 367 when ' ' 368 "%#{@width || @default_width}d" 369 else 370 "%#{@padchar}#{@width || @default_width}d" 371 end 372 end
multiplier()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 400 def multiplier 401 0 402 end
nanoseconds(group)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 396 def nanoseconds(group) 397 group.to_i * multiplier 398 end
set_use_total()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 404 def set_use_total 405 @use_total = true 406 end
use_total?()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 408 def use_total? 409 @use_total 410 end