Class: ExampleGroupTimer::TimedGroup
- Defined in:
- lib/example_group_timer/timed_group.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_example ⇒ Object
readonly
Returns the value of attribute current_example.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#subgroups ⇒ Object
readonly
Returns the value of attribute subgroups.
Attributes inherited from TimedItem
Instance Method Summary collapse
- #add_example(example) ⇒ Object
- #add_group(group) ⇒ Object
- #finish_current_example ⇒ Object
-
#initialize(*args) ⇒ TimedGroup
constructor
A new instance of TimedGroup.
- #report ⇒ Object
Methods inherited from TimedItem
#description, #duration, #finish, #indent, #percentage, #puts, #start
Constructor Details
#initialize(*args) ⇒ TimedGroup
Returns a new instance of TimedGroup.
5 6 7 8 |
# File 'lib/example_group_timer/timed_group.rb', line 5 def initialize(*args) super @subgroups, @examples = [], [] end |
Instance Attribute Details
#current_example ⇒ Object (readonly)
Returns the value of attribute current_example.
3 4 5 |
# File 'lib/example_group_timer/timed_group.rb', line 3 def current_example @current_example end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
3 4 5 |
# File 'lib/example_group_timer/timed_group.rb', line 3 def examples @examples end |
#subgroups ⇒ Object (readonly)
Returns the value of attribute subgroups.
3 4 5 |
# File 'lib/example_group_timer/timed_group.rb', line 3 def subgroups @subgroups end |
Instance Method Details
#add_example(example) ⇒ Object
16 17 18 19 |
# File 'lib/example_group_timer/timed_group.rb', line 16 def add_example(example) @current_example = TimedItem.new(example, self) examples << @current_example end |
#add_group(group) ⇒ Object
10 11 12 13 14 |
# File 'lib/example_group_timer/timed_group.rb', line 10 def add_group(group) g = TimedGroup.new(group, self) @subgroups << g g end |
#finish_current_example ⇒ Object
21 22 23 24 |
# File 'lib/example_group_timer/timed_group.rb', line 21 def finish_current_example @current_example.finish @current_example = nil end |
#report ⇒ Object
26 27 28 29 30 31 |
# File 'lib/example_group_timer/timed_group.rb', line 26 def report super puts "<ol>" (examples + subgroups).sort_by(&:duration).reverse.each(&:report) puts "</ol>" end |