Class: RSpec::By::Formatter::Bullet
- Inherits:
-
Object
- Object
- RSpec::By::Formatter::Bullet
- Defined in:
- lib/rspec/by/formatter.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #delta_t ⇒ Object
- #format_seconds(float, precision = 2) ⇒ Object
- #format_time(duration) ⇒ Object
-
#initialize(message = '', nested = false) ⇒ Bullet
constructor
A new instance of Bullet.
- #nest ⇒ Object
- #nested? ⇒ Boolean
- #offset ⇒ Object
Constructor Details
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
92 93 94 |
# File 'lib/rspec/by/formatter.rb', line 92 def @message end |
Instance Method Details
#delta_t ⇒ Object
99 100 101 102 |
# File 'lib/rspec/by/formatter.rb', line 99 def delta_t delta_t = RSpec::Core::Time.now - @t0 format_time(delta_t) end |
#format_seconds(float, precision = 2) ⇒ Object
126 127 128 129 |
# File 'lib/rspec/by/formatter.rb', line 126 def format_seconds(float, precision = 2) #precision ||= (float < 1) ? 5 : 2 sprintf("%.#{precision}f", float) end |
#format_time(duration) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/rspec/by/formatter.rb', line 116 def format_time(duration) if duration > 60 minutes = duration.to_i / 60 seconds = duration - minutes * 60 "#{minutes}m #{format_seconds(seconds)}s" else "#{format_seconds(duration)}s" end end |
#nest ⇒ Object
108 109 110 |
# File 'lib/rspec/by/formatter.rb', line 108 def nest @nested = true end |
#nested? ⇒ Boolean
112 113 114 |
# File 'lib/rspec/by/formatter.rb', line 112 def nested? @nested end |
#offset ⇒ Object
104 105 106 |
# File 'lib/rspec/by/formatter.rb', line 104 def offset @message.size end |