Class: CoderwallRuby::User

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/coderwall_ruby/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ User

Returns a new instance of User.



8
9
10
# File 'lib/coderwall_ruby/user.rb', line 8

def initialize(username)
  self.username = username
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/coderwall_ruby/user.rb', line 16

def method_missing(name, *args, &block)
  if profile.has_key?(name.to_s)
    profile[name.to_s]
  else
    super
  end
end

Instance Attribute Details

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/coderwall_ruby/user.rb', line 6

def username
  @username
end

Instance Method Details

#profileObject



12
13
14
# File 'lib/coderwall_ruby/user.rb', line 12

def profile
  self.class.get "/#{ username }.json" 
end