Class: Course::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/course/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, block, **options) ⇒ Step

Returns a new instance of Step.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
# File 'lib/course/step.rb', line 7

def initialize(target, block, **options)
  raise ArgumentError, 'Cannot create a step with both name and block' if !target.nil? && !block.nil?
  raise ArgumentError, 'Step name or block should be passed' if target.nil? && block.nil?

  @target = target
  @options = options
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



5
6
7
# File 'lib/course/step.rb', line 5

def block
  @block
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/course/step.rb', line 5

def options
  @options
end

#targetObject (readonly)

Returns the value of attribute target.



5
6
7
# File 'lib/course/step.rb', line 5

def target
  @target
end

Instance Method Details

#block?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/course/step.rb', line 20

def block?
  !@block.nil?
end

#method?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/course/step.rb', line 16

def method?
  target.is_a?(String) || target.is_a?(Symbol)
end