Class: Step
- Inherits:
-
Object
- Object
- Step
- Defined in:
- lib/completion-progress/step.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#name ⇒ Object
Returns the value of attribute name.
-
#result ⇒ Object
Returns the value of attribute result.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value, options = {}, &block) ⇒ Step
constructor
A new instance of Step.
- #process(obj) ⇒ Object
Constructor Details
#initialize(name, value, options = {}, &block) ⇒ Step
Returns a new instance of Step.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/completion-progress/step.rb', line 6 def initialize(name, value, = {}, &block) @name = name @value = value @block = block @result = false if (.has_key?(:hint)) @hint = Hint.new(self, [:hint][:text], [:hint][:href], [:hint][:options]) else @hint = Hint.new(self, "Fill #{name}") end end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
4 5 6 |
# File 'lib/completion-progress/step.rb', line 4 def block @block end |
#hint ⇒ Object
Returns the value of attribute hint.
4 5 6 |
# File 'lib/completion-progress/step.rb', line 4 def hint @hint end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/completion-progress/step.rb', line 4 def name @name end |
#result ⇒ Object
Returns the value of attribute result.
4 5 6 |
# File 'lib/completion-progress/step.rb', line 4 def result @result end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/completion-progress/step.rb', line 4 def value @value end |
Instance Method Details
#process(obj) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/completion-progress/step.rb', line 19 def process(obj) begin if !@block val = obj.send(@name) else val = obj.instance_eval(&@block) end if val.kind_of?(Array) or val.kind_of?(Hash) @result = val.count == 0 ? false : true else @result = val end rescue Exception => e @result = false ensure @result ? @result = true : @result = false end end |