Class: Gantty::GanttChart
- Inherits:
-
Object
- Object
- Gantty::GanttChart
- Defined in:
- lib/gantty.rb
Instance Attribute Summary collapse
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
- #current_tasks(date = Date.today) ⇒ Object
-
#initialize(file = nil) ⇒ GanttChart
constructor
A new instance of GanttChart.
- #parse_gantt ⇒ Object
Constructor Details
#initialize(file = nil) ⇒ GanttChart
Returns a new instance of GanttChart.
16 17 18 19 20 21 22 23 |
# File 'lib/gantty.rb', line 16 def initialize file = nil @gantt = nil @resources, @tasks = [], [] if file @gantt = Nokogiri::XML(open(File.(file))) parse_gantt end end |
Instance Attribute Details
#resources ⇒ Object
Returns the value of attribute resources.
14 15 16 |
# File 'lib/gantty.rb', line 14 def resources @resources end |
#tasks ⇒ Object
Returns the value of attribute tasks.
14 15 16 |
# File 'lib/gantty.rb', line 14 def tasks @tasks end |
Instance Method Details
#current_tasks(date = Date.today) ⇒ Object
31 32 33 |
# File 'lib/gantty.rb', line 31 def current_tasks date = Date.today @tasks.select { |t| t.start <= date and t.end >= date } end |
#parse_gantt ⇒ Object
25 26 27 28 29 |
# File 'lib/gantty.rb', line 25 def parse_gantt @gantt.xpath('//resource').each { |r| @resources << Resource.new(r) } @gantt.xpath('//task').each { |t| @tasks << Task.new(t) } @tasks.each { |task| @gantt.xpath("//allocation[@task-id=#{task.id}]").each { |alloc| task.coordinators += @resources.select { |r| r.id == alloc.attributes["resource-id"].to_i } } } end |