class Step

Attributes

block[RW]
hint[RW]
name[RW]
result[RW]
value[RW]

Public Class Methods

new(name, value, options = {}, &block) click to toggle source
# File lib/completion-progress/step.rb, line 6
def initialize(name, value, options = {}, &block)
  @name = name
  @value = value
  @block = block
  @result = false

  if (options.has_key?(:hint))
    @hint = Hint.new(self, options[:hint][:text], options[:hint][:href], options[:hint][:options])
  else
    @hint = Hint.new(self, "Fill #{name}")
  end
end

Public Instance Methods

process(obj) click to toggle source
# 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