Class: Gantty::Resource
- Inherits:
-
Object
- Object
- Gantty::Resource
- Defined in:
- lib/gantty.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
The e-mail address of the resource.
-
#id ⇒ Object
readonly
The GanttProject
id
field of the resource. -
#name ⇒ Object
The name of the resource.
-
#phone ⇒ Object
The phone number of the resource.
Instance Method Summary collapse
-
#initialize(r) ⇒ Resource
constructor
A new instance of Resource.
- #to_xml ⇒ Object
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
#email ⇒ Object
The e-mail address of the resource.
463 464 465 |
# File 'lib/gantty.rb', line 463 def email @email end |
#id ⇒ Object (readonly)
The GanttProject id
field of the resource.
469 470 471 |
# File 'lib/gantty.rb', line 469 def id @id end |
#name ⇒ Object
The name of the resource. Cannot be empty.
460 461 462 |
# File 'lib/gantty.rb', line 460 def name @name end |
#phone ⇒ Object
The phone number of the resource.
466 467 468 |
# File 'lib/gantty.rb', line 466 def phone @phone end |
Instance Method Details
#to_xml ⇒ Object
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 |