Class: Sqrbl::Group
- 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
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#conversion ⇒ Object
readonly
Returns the value of attribute conversion.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(conversion, description, options = {}, &block) ⇒ Group
constructor
A new instance of Group.
-
#step(step_description, &block) ⇒ Object
Creates a StepPair object, passing it the step_description and block arguments.
- #unix_name ⇒ Object
-
#valid? ⇒ Boolean
A Group is valid if it contains at least one StepPair object, and all of those objects are themselves valid.
Methods included from HasTodos
Methods included from MethodMissingDelegation
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, = {}, &block) @conversion = conversion @description = description @block = lambda(&block) @steps = [] eval_block_on_initialize() end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
12 13 14 |
# File 'lib/sqrbl/group.rb', line 12 def block @block end |
#conversion ⇒ Object (readonly)
Returns the value of attribute conversion.
12 13 14 |
# File 'lib/sqrbl/group.rb', line 12 def conversion @conversion end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/sqrbl/group.rb', line 12 def description @description end |
#steps ⇒ Object (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_name ⇒ Object
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.
34 35 36 |
# File 'lib/sqrbl/group.rb', line 34 def valid? !steps.empty? && steps.all? { |step| step.kind_of?(StepPair) && step.valid? } end |