Class: Gantty::Task
- Inherits:
-
Object
- Object
- Gantty::Task
- Defined in:
- lib/gantty.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#coordinators ⇒ Object
Returns the value of attribute coordinators.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#end ⇒ Object
Returns the value of attribute end.
-
#finishes_before ⇒ Object
Returns the value of attribute finishes_before.
-
#finishes_with ⇒ Object
Returns the value of attribute finishes_with.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#percent_complete ⇒ Object
Returns the value of attribute percent_complete.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#start ⇒ Object
Returns the value of attribute start.
-
#starts_after ⇒ Object
Returns the value of attribute starts_after.
-
#starts_with ⇒ Object
Returns the value of attribute starts_with.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
- #add_finishes_before(t) ⇒ Object
- #add_finishes_with(t) ⇒ Object
- #add_resource(resource) ⇒ Object
- #add_starts_after(t) ⇒ Object
-
#add_starts_with(t) ⇒ Object
If Task B has predecessor Task A with relationship Finish->Start, task_b.before.include? task_a <task id=“#task_atask_a.id”…><depend id=“#task_btask_b.id” type=“2” difference=“1” hardness=“Rubber”/></task> Start-Start: 1 => #starts_with Finish-Start: 2 => #starts_after Finish-Finish: 3 => #finishes_with Start-Finish: 4 => #finishes_before.
-
#initialize(t) ⇒ Task
constructor
A new instance of Task.
- #xml_coordinator_properties ⇒ Object
- #xml_properties ⇒ Object
Constructor Details
#initialize(t) ⇒ Task
Returns a new instance of Task.
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/gantty.rb', line 267 def initialize t @notes = nil @starts_with, @starts_after, @finishes_with, @finishes_before, @tasks = [], [], [], [], [] if t.is_a? Hash @name = t[:name] elsif t.is_a? String raise ArgumentError, "name cannot be blank" if t.length == 0 @name = t else @name = t.attributes["name"] @start = Date.strptime(t.attributes["start"]) @duration = t.attributes["duration"].to_i @priority = PRIORITY[t.attributes["priority"].to_i] @end = @start + @duration @percent_complete = t.attributes["complete"].to_i @coordinators = [] @color = t.attributes["color"] @id = t.attributes["id"].to_i @link = (t.attributes.include?("webLink") ? t.attributes["webLink"] : nil) t.children.select { |c| c.name == "notes" }.each do |note| @notes = note.inner_text end end end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
262 263 264 |
# File 'lib/gantty.rb', line 262 def color @color end |
#coordinators ⇒ Object
Returns the value of attribute coordinators.
261 262 263 |
# File 'lib/gantty.rb', line 261 def coordinators @coordinators end |
#duration ⇒ Object
Returns the value of attribute duration.
261 262 263 |
# File 'lib/gantty.rb', line 261 def duration @duration end |
#end ⇒ Object
Returns the value of attribute end.
261 262 263 |
# File 'lib/gantty.rb', line 261 def end @end end |
#finishes_before ⇒ Object
Returns the value of attribute finishes_before.
262 263 264 |
# File 'lib/gantty.rb', line 262 def finishes_before @finishes_before end |
#finishes_with ⇒ Object
Returns the value of attribute finishes_with.
262 263 264 |
# File 'lib/gantty.rb', line 262 def finishes_with @finishes_with end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
265 266 267 |
# File 'lib/gantty.rb', line 265 def id @id end |
#link ⇒ Object
Returns the value of attribute link.
263 264 265 |
# File 'lib/gantty.rb', line 263 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
261 262 263 |
# File 'lib/gantty.rb', line 261 def name @name end |
#notes ⇒ Object
Returns the value of attribute notes.
263 264 265 |
# File 'lib/gantty.rb', line 263 def notes @notes end |
#percent_complete ⇒ Object
Returns the value of attribute percent_complete.
261 262 263 |
# File 'lib/gantty.rb', line 261 def percent_complete @percent_complete end |
#priority ⇒ Object
Returns the value of attribute priority.
261 262 263 |
# File 'lib/gantty.rb', line 261 def priority @priority end |
#start ⇒ Object
Returns the value of attribute start.
261 262 263 |
# File 'lib/gantty.rb', line 261 def start @start end |
#starts_after ⇒ Object
Returns the value of attribute starts_after.
262 263 264 |
# File 'lib/gantty.rb', line 262 def starts_after @starts_after end |
#starts_with ⇒ Object
Returns the value of attribute starts_with.
262 263 264 |
# File 'lib/gantty.rb', line 262 def starts_with @starts_with end |
#tasks ⇒ Object
Returns the value of attribute tasks.
263 264 265 |
# File 'lib/gantty.rb', line 263 def tasks @tasks end |
Instance Method Details
#add_finishes_before(t) ⇒ Object
366 367 368 |
# File 'lib/gantty.rb', line 366 def add_finishes_before t @finishes_before << t end |
#add_finishes_with(t) ⇒ Object
362 363 364 |
# File 'lib/gantty.rb', line 362 def add_finishes_with t @finishes_with << t end |
#add_resource(resource) ⇒ Object
292 293 294 |
# File 'lib/gantty.rb', line 292 def add_resource resource (@coordinators ||= []) << resource end |
#add_starts_after(t) ⇒ Object
358 359 360 |
# File 'lib/gantty.rb', line 358 def add_starts_after t @starts_after << t end |
#add_starts_with(t) ⇒ Object
If Task B has predecessor Task A with relationship Finish->Start, task_b.before.include? task_a <task id=“#Gantty::Task.task_atask_a.id”…><depend id=“#Gantty::Task.task_btask_b.id” type=“2” difference=“1” hardness=“Rubber”/></task> Start-Start: 1 => #starts_with Finish-Start: 2 => #starts_after Finish-Finish: 3 => #finishes_with Start-Finish: 4 => #finishes_before
354 355 356 |
# File 'lib/gantty.rb', line 354 def add_starts_with t @starts_with << t end |
#xml_coordinator_properties ⇒ Object
336 337 338 339 340 341 342 343 |
# File 'lib/gantty.rb', line 336 def xml_coordinator_properties res = [] return res unless @coordinators @coordinators.each do |coordinator| res << {"task-id" => id, "resource-id" => coordinator.id, :function => "Default:0", :responsible => true, :load => 100.0 } end return res end |
#xml_properties ⇒ Object
329 330 331 332 333 334 |
# File 'lib/gantty.rb', line 329 def xml_properties properties = { :id => id, :name => name, :color => color, :meeting => false, :start => start.strftime("%Y-%m-%d"), :duration => duration, :complete => percent_complete, :priority => PRIORITY[priority], :expand => false } properties.merge!( :webLink => @link ) if @link return properties end |