Class: Puppet::Pops::Time::Timespan::Format::NanoSecondSegment
- Inherits:
-
FragmentSegment
- Object
- Segment
- ValueSegment
- FragmentSegment
- Puppet::Pops::Time::Timespan::Format::NanoSecondSegment
- Defined in:
- lib/puppet/pops/time/timespan.rb
Instance Method Summary collapse
- #append_to(bld, ts) ⇒ Object
-
#initialize(padchar, width) ⇒ NanoSecondSegment
constructor
A new instance of NanoSecondSegment.
- #multiplier ⇒ Object
Methods inherited from FragmentSegment
#append_value, #create_format, #nanoseconds
Methods inherited from ValueSegment
#append_regexp, #append_value, #create_format, #nanoseconds, #set_use_total, #use_total?
Methods inherited from Segment
Constructor Details
#initialize(padchar, width) ⇒ NanoSecondSegment
Returns a new instance of NanoSecondSegment.
512 513 514 |
# File 'lib/puppet/pops/time/timespan.rb', line 512 def initialize(padchar, width) super(padchar, width, 9) end |
Instance Method Details
#append_to(bld, ts) ⇒ Object
525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'lib/puppet/pops/time/timespan.rb', line 525 def append_to(bld, ts) ns = ts.total_nanoseconds width = @width || @default_width if width < 9 # Truncate digits to the right, i.e. let %6N reflect microseconds ns /= 10 ** (9 - width) ns %= 10 ** width unless use_total? else ns %= NSECS_PER_SEC unless use_total? end append_value(bld, ns) end |
#multiplier ⇒ Object
516 517 518 519 520 521 522 523 |
# File 'lib/puppet/pops/time/timespan.rb', line 516 def multiplier width = @width || @default_width if width < 9 10 ** (9 - width) else 1 end end |