Class: ExampleGroupTimer::TimedGroup

Inherits:
TimedItem
  • Object
show all
Defined in:
lib/example_group_timer/timed_group.rb

Direct Known Subclasses

RootTimedGroup

Instance Attribute Summary collapse

Attributes inherited from TimedItem

#item, #parent

Instance Method Summary collapse

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_exampleObject (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

#examplesObject (readonly)

Returns the value of attribute examples.



3
4
5
# File 'lib/example_group_timer/timed_group.rb', line 3

def examples
  @examples
end

#subgroupsObject (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_exampleObject



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

#reportObject



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