Sha256: 5ee19c745a0d6da7a61459959a19d4c6be59a3e4192f25835cfda637ec65e272
Contents?: true
Size: 965 Bytes
Versions: 2
Compression:
Stored size: 965 Bytes
Contents
require 'plist' require 'rjobs/command_builder' require 'colorize' module Rjobs class Job attr_accessor :id, :name, :status attr_writer :params, :command def initialize(id=0,xml="") @id = id parse(xml) @params= {} @command = "" end def xml=(xml) parse(xml) end def command cb = Rjobs::CommandBuilder.new(@command,@params) cb.build end def status_with_color case @status when /Finished/ @status.green when /Failed/ @status.light_red when /Not Exist/ @status.red else @status end end private def parse(xml) return if xml.empty? result = Plist::parse_xml(xml) @name = result['jobAttributes'].nil? ? "" : result['jobAttributes']['name'] @status = result['jobAttributes'].nil? ? "Not Exist" : result['jobAttributes']['jobStatus'] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rjobs-0.2.0.alpha | lib/rjobs/job.rb |
rjobs-0.1.0.alpha | lib/rjobs/job.rb |