Class: MyExperimentREST::MyExperimentUser

Inherits:
Object
  • Object
show all
Defined in:
lib/myexperiment-rest/user.rb

Overview

Contains information about a user. All basic information is available but not some of the more advanced like all user’s friends or workflow’s.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ MyExperimentUser

Returns a new instance of MyExperimentUser.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/myexperiment-rest/user.rb', line 50

def initialize(attributes)
  @id = attributes[:id]
  @created_at = attributes[:created_at]
  @name = attributes[:name]
  @description = attributes[:description]
  @email = attributes[:email]
  @avatar_uri = attributes[:avatar_uri]
  @city = attributes[:city]
  @country = attributes[:country]
  @website = attributes[:website]
end

Instance Attribute Details

#avatar_uriObject (readonly)

Returns the value of attribute avatar_uri.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def avatar_uri
  @avatar_uri
end

#cityObject (readonly)

Returns the value of attribute city.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def country
  @country
end

#created_atObject (readonly)

Returns the value of attribute created_at.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def description
  @description
end

#emailObject (readonly)

Returns the value of attribute email.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def name
  @name
end

#websiteObject (readonly)

Returns the value of attribute website.



48
49
50
# File 'lib/myexperiment-rest/user.rb', line 48

def website
  @website
end

Class Method Details

.parse(xml) ⇒ Object

Acquire data from XML response and instantiate a MyExperimentWorkflow object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/myexperiment-rest/user.rb', line 64

def self.parse(xml)

  doc = LibXML::XML::Document.string(xml)

  new(:id => doc.find_first("/user/id").content,
      :created_at => doc.find_first("/user/created-at").content,
      :name => doc.find_first("/user/name").content,
      :description => doc.find_first("/user/description").content,
      :email => doc.find_first("/user/email").content,
      :avatar_uri => doc.find_first("/user/avatar").attributes[:uri],
      :city => doc.find_first("/user/city").content,
      :country => doc.find_first("/user/country").content,
      :website => doc.find_first("/user/website").content)

end