Class: Gantty::Resource
- Inherits:
-
Object
- Object
- Gantty::Resource
- Defined in:
- lib/gantty.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
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.
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
#email ⇒ Object
Returns the value of attribute email.
373 374 375 |
# File 'lib/gantty.rb', line 373 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
374 375 376 |
# File 'lib/gantty.rb', line 374 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
373 374 375 |
# File 'lib/gantty.rb', line 373 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
373 374 375 |
# File 'lib/gantty.rb', line 373 def phone @phone end |
Instance Method Details
#to_xml ⇒ Object
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 |