Class: Sqrbl::Group

Inherits:
Object show all
Includes:
ExpectsBlockWithNew, HasTodos, MethodMissingDelegation
Defined in:
lib/sqrbl/group.rb

Overview

Like the Conversion class, Group doesn’t do much on its own. It’s basically a container for a list of StepPair objects, which are created using #step.

Group delegates method_missing calls to its conversion object. For more information, see MethodMissingDelegation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasTodos

#todo, #todos, #warning

Methods included from MethodMissingDelegation

included

Constructor Details

#initialize(conversion, description, options = {}, &block) ⇒ Group

Returns a new instance of Group.



19
20
21
22
23
24
25
26
# File 'lib/sqrbl/group.rb', line 19

def initialize(conversion, description, options = {}, &block)
  @conversion   = conversion
  @description = description
  @block       = lambda(&block)
  @steps       = []

  eval_block_on_initialize(options)
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



12
13
14
# File 'lib/sqrbl/group.rb', line 12

def block
  @block
end

#conversionObject (readonly)

Returns the value of attribute conversion.



12
13
14
# File 'lib/sqrbl/group.rb', line 12

def conversion
  @conversion
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/sqrbl/group.rb', line 12

def description
  @description
end

#stepsObject (readonly)

Returns the value of attribute steps.



12
13
14
# File 'lib/sqrbl/group.rb', line 12

def steps
  @steps
end

Instance Method Details

#step(step_description, &block) ⇒ Object

Creates a StepPair object, passing it the step_description and block arguments.



29
30
31
# File 'lib/sqrbl/group.rb', line 29

def step(step_description, &block)
  steps << StepPair.new(self, step_description, &block)
end

#unix_nameObject



38
39
40
# File 'lib/sqrbl/group.rb', line 38

def unix_name
  Sqrbl.calculate_unix_name(description)
end

#valid?Boolean

A Group is valid if it contains at least one StepPair object, and all of those objects are themselves valid.

Returns:

  • (Boolean)


34
35
36
# File 'lib/sqrbl/group.rb', line 34

def valid?
  !steps.empty? && steps.all? { |step| step.kind_of?(StepPair) && step.valid? }
end