class OFlow::Graffle::TaskInfo

Attributes

bounds[RW]
color[RW]
line_id[RW]
name[RW]
options[RW]
shape[RW]

Public Class Methods

new(nodes) click to toggle source
Calls superclass method OFlow::Graffle::Element::new
# File lib/oflow/graffle.rb, line 222
def initialize(nodes)
  super
  if (ln = Graffle.get_key_value(nodes, 'Line')).nil?
    @line_id = nil
  else
    @line_id = Graffle.get_key_value(ln, 'ID')
  end
  @shape = Graffle.get_key_value(nodes, 'Shape')
  color_node = Graffle.get_key_value(Graffle.get_key_value(Graffle.get_key_value(nodes, 'Style'), 'fill'), 'Color')
  if color_node.nil?
    @color = nil
  else
    @color = [Graffle.get_key_value(color_node, 'r').to_f,
              Graffle.get_key_value(color_node, 'g').to_f,
              Graffle.get_key_value(color_node, 'b').to_f]
  end
  unless (@bounds = Graffle.get_key_value(nodes, 'Bounds')).nil?
    @bounds = @bounds.delete('{}').split(',')
    @bounds.map! { |s| s.to_i }
  end
  @options = { }
  text = Graffle.get_text(Graffle.get_key_value(nodes, 'Text'))
  unless text.nil?
    text.split("\n").each do |line|
      pair = line.split(':', 2)
      if 1 == pair.length
        @name = pair[0]
      else
        k = pair[0]
        if 0 == k.length
          k = nil
        else
          k = k.to_sym
        end
        @options[k] = pair[1]
      end
    end
  end
end

Public Instance Methods

first_option() click to toggle source
# File lib/oflow/graffle.rb, line 262
def first_option()
  target = nil
  op = nil
  if name.nil?
    options.each { |k,v| target, op = k, v; break }
  else
    target = name
  end
  [target, op]
end
get_class() click to toggle source
# File lib/oflow/graffle.rb, line 273
def get_class()
  return nil if options.nil?
  return nil if (s = options[:class]).nil?
  s.strip!
  c = nil
  begin
    # TBD search all modules and classes for a match that is also an Actor

    # Assume the environment is safe since it is being used to create
    # processes from user provided code anyway.
    c = Object.class_eval(s)
  rescue Exception
    c = ::OFlow::Actors.module_eval(s)
  end
  c
end
to_s() click to toggle source
# File lib/oflow/graffle.rb, line 290
def to_s()
  "TaskInfo{id:#{@id}, line_id:#{line_id}, name: #{name}, options: #{options}, bounds: #{@bounds}, shape: #{@shape}, color: #{@color}}"
end