Sha256: 57844aa00a2ecfda58db85716ed10d6c95c94c47db73d7ebf4d1c86381ae75e4
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 Bytes
Contents
# coding: utf-8 module Abak::Flow class Visitor def initialize(*args) options = args.pop if args.last.is_a?(Hash) @objects = args @call = options.fetch(:call) @info = options.fetch(:look_for) @asked = false end def ready? @asked = true ready = @objects.map { |o| o.send(@call) }.uniq ready.size == 1 && ready.first end def output ready? unless asked? @objects.map do |o| next if o.send(@info).empty? info = "" name = o.respond_to?(:display_name) ? o.display_name : o.class.name o.send(@info).each_with_index do |inf, idx| info << "\n #{idx + 1}. #{inf}" end "\n#{name}#{info}" end * "\n" end private def asked? @asked end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
abak-flow-1.0.1 | lib/abak-flow/visitor.rb |
abak-flow-1.0.0 | lib/abak-flow/visitor.rb |