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.



376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/gantty.rb', line 376

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

Returns the value of attribute email.



373
374
375
# File 'lib/gantty.rb', line 373

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



374
375
376
# File 'lib/gantty.rb', line 374

def id
  @id
end

#nameObject

Returns the value of attribute name.



373
374
375
# File 'lib/gantty.rb', line 373

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



373
374
375
# File 'lib/gantty.rb', line 373

def phone
  @phone
end

Instance Method Details

#to_xmlObject



390
391
392
393
# File 'lib/gantty.rb', line 390

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