Class: Viiite::Tms
- Inherits:
-
Struct
- Object
- Struct
- Viiite::Tms
- Defined in:
- lib/viiite/tms.rb
Constant Summary
- FORMAT =
"%10.6u %10.6y %10.6t %10.6r"
Instance Attribute Summary (collapse)
-
- (Object) cstime
Returns the value of attribute cstime.
-
- (Object) cutime
Returns the value of attribute cutime.
-
- (Object) real
Returns the value of attribute real.
-
- (Object) stime
(also: #system)
Returns the value of attribute stime.
-
- (Object) utime
(also: #user)
Returns the value of attribute utime.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) *(other)
- - (Object) +(other)
- - (Object) -(other)
- - (Object) /(other)
- - (Object) coerce(other)
- - (Object) format(format = nil, *args) (also: #to_s)
-
- (Tms) initialize(utime, stime, cutime, cstime, real)
constructor
A new instance of Tms.
- - (Object) members
- - (Object) to_h
- - (Object) to_ruby_literal
- - (Object) total
Constructor Details
- (Tms) initialize(utime, stime, cutime, cstime, real)
A new instance of Tms
6 7 8 |
# File 'lib/viiite/tms.rb', line 6 def initialize(utime, stime, cutime, cstime, real) super # ensure we have all 5 non-nil arguments end |
Instance Attribute Details
- (Object) cstime
Returns the value of attribute cstime
2 3 4 |
# File 'lib/viiite/tms.rb', line 2 def cstime @cstime end |
- (Object) cutime
Returns the value of attribute cutime
2 3 4 |
# File 'lib/viiite/tms.rb', line 2 def cutime @cutime end |
- (Object) real
Returns the value of attribute real
2 3 4 |
# File 'lib/viiite/tms.rb', line 2 def real @real end |
- (Object) stime Also known as: system
Returns the value of attribute stime
2 3 4 |
# File 'lib/viiite/tms.rb', line 2 def stime @stime end |
- (Object) utime Also known as: user
Returns the value of attribute utime
2 3 4 |
# File 'lib/viiite/tms.rb', line 2 def utime @utime end |
Class Method Details
+ (Object) coerce(arg)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/viiite/tms.rb', line 10 def self.coerce(arg) case arg when Viiite::Tms arg when Numeric Viiite::Tms.new arg, 0.0, 0.0, 0.0, 0.0 when Hash Viiite::Tms.new(*members.collect{|f| arg[f] || 0.0}) when Array Viiite::Tms.new(*arg) else raise ArgumentError, "Invalid value #{arg.inspect} for Viiite::Tms" end end |
+ (Object) members
75 |
# File 'lib/viiite/tms.rb', line 75 def self.members; super.map(&:to_sym); end |
Instance Method Details
- (Object) *(other)
38 |
# File 'lib/viiite/tms.rb', line 38 def *(other); memberwise(:*, other) end |
- (Object) +(other)
36 |
# File 'lib/viiite/tms.rb', line 36 def +(other); memberwise(:+, other) end |
- (Object) -(other)
37 |
# File 'lib/viiite/tms.rb', line 37 def -(other); memberwise(:-, other) end |
- (Object) /(other)
39 |
# File 'lib/viiite/tms.rb', line 39 def /(other); memberwise(:/, other) end |
- (Object) coerce(other)
41 42 43 |
# File 'lib/viiite/tms.rb', line 41 def coerce(other) [self, other] end |
- (Object) format(format = nil, *args) Also known as: to_s
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/viiite/tms.rb', line 49 def format(format = nil, *args) str = (format || FORMAT).dup str.gsub!(/(%[-+.\d]*)u/) { "#{$1}f" % utime } str.gsub!(/(%[-+.\d]*)y/) { "#{$1}f" % stime } str.gsub!(/(%[-+.\d]*)U/) { "#{$1}f" % cutime } str.gsub!(/(%[-+.\d]*)Y/) { "#{$1}f" % cstime } str.gsub!(/(%[-+.\d]*)t/) { "#{$1}f" % total } str.gsub!(/(%[-+.\d]*)r/) { "(#{$1}f)" % real } format ? str % args : str end |
- (Object) members
74 |
# File 'lib/viiite/tms.rb', line 74 def members; super.map(&:to_sym); end |
- (Object) to_h
45 46 47 |
# File 'lib/viiite/tms.rb', line 45 def to_h @to_h ||= Hash[members.zip(values)] end |
- (Object) to_ruby_literal
32 33 34 |
# File 'lib/viiite/tms.rb', line 32 def to_ruby_literal "Viiite::Tms(#{to_a.collect{|f| f.inspect}.join(',')})" end |
- (Object) total
28 29 30 |
# File 'lib/viiite/tms.rb', line 28 def total cutime + cstime + stime + utime end |