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 354 def initialize(padchar, width, default_width) 355 @use_total = false 356 @padchar = padchar 357 @width = width 358 @default_width = default_width 359 @format = create_format 360 end
Public Instance Methods
append_regexp(bld)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 373 def append_regexp(bld) 374 if @width.nil? 375 case @padchar 376 when nil 377 bld << (use_total? ? '([0-9]+)' : "([0-9]{1,#{@default_width}})") 378 when '0' 379 bld << (use_total? ? '([0-9]+)' : "([0-9]{1,#{@default_width}})") 380 else 381 bld << (use_total? ? '\s*([0-9]+)' : "([0-9\\s]{1,#{@default_width}})") 382 end 383 else 384 case @padchar 385 when nil 386 bld << "([0-9]{1,#{@width}})" 387 when '0' 388 bld << "([0-9]{#{@width}})" 389 else 390 bld << "([0-9\\s]{#{@width}})" 391 end 392 end 393 end
append_value(bld, n)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 411 def append_value(bld, n) 412 bld << sprintf(@format, n) 413 end
create_format()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 362 def create_format 363 case @padchar 364 when nil 365 '%d' 366 when ' ' 367 "%#{@width || @default_width}d" 368 else 369 "%#{@padchar}#{@width || @default_width}d" 370 end 371 end
multiplier()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 399 def multiplier 400 0 401 end
nanoseconds(group)
click to toggle source
# File lib/puppet/pops/time/timespan.rb 395 def nanoseconds(group) 396 group.to_i * multiplier 397 end
set_use_total()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 403 def set_use_total 404 @use_total = true 405 end
use_total?()
click to toggle source
# File lib/puppet/pops/time/timespan.rb 407 def use_total? 408 @use_total 409 end