Class: Gantty::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/gantty.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r) ⇒ Resource

Returns a new instance of Resource.



471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/gantty.rb', line 471

def initialize r
  if r.is_a? Hash
    @name = r[:name]
  elsif r.is_a? String
    raise ArgumentError, "name cannot be blank" if r.length == 0
    @name = r
  else
    @name = r.attributes["name"]
    @phone = r.attributes["phone"]
    @email = r.attributes["contacts"]
    @id = r.attributes["id"].to_i
  end
end

Instance Attribute Details

#emailObject

The e-mail address of the resource.



463
464
465
# File 'lib/gantty.rb', line 463

def email
  @email
end

#idObject (readonly)

The GanttProject id field of the resource.



469
470
471
# File 'lib/gantty.rb', line 469

def id
  @id
end

#nameObject

The name of the resource. Cannot be empty.



460
461
462
# File 'lib/gantty.rb', line 460

def name
  @name
end

#phoneObject

The phone number of the resource.



466
467
468
# File 'lib/gantty.rb', line 466

def phone
  @phone
end

Instance Method Details

#to_xmlObject



485
486
487
488
# File 'lib/gantty.rb', line 485

def to_xml
  x = Builder::XmlMarkup.new :indent => 2
  xml = x.resource( { :id => id, :name => name, :phone => phone, :contacts => email, :function=> "Default:0" } )
end