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.
518 519 520 |
# File 'lib/puppet/pops/time/timespan.rb', line 518 def initialize(padchar, width) super(padchar, width, 9) end |
Instance Method Details
#append_to(bld, ts) ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/puppet/pops/time/timespan.rb', line 531 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
522 523 524 525 526 527 528 529 |
# File 'lib/puppet/pops/time/timespan.rb', line 522 def multiplier width = @width || @default_width if width < 9 10**(9 - width) else 1 end end |