Class: Coderwall::User

Inherits:
Object
  • Object
show all
Defined in:
lib/coderwall-ruby-api.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, send_request = true) ⇒ User

Returns a new instance of User.



10
11
12
13
# File 'lib/coderwall-ruby-api.rb', line 10

def initialize(username, send_request=true)
	username.empty? ? invalid_username : @username = username.to_s
	make_http_request if send_request
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object (private)



18
19
20
21
# File 'lib/coderwall-ruby-api.rb', line 18

def method_missing(*args)
 make_http_request
 return @user_data[args[0].to_s] || super		
end

Class Method Details

.achievements_of(username) ⇒ Object Also known as: achievements



52
53
54
# File 'lib/coderwall-ruby-api.rb', line 52

def achievements_of(username)
	self.badges(username)
end

.method_missing(*args) ⇒ Object



44
45
46
# File 'lib/coderwall-ruby-api.rb', line 44

def method_missing(*args)
	self.new(args[1]).send(args[0])
end

.name(username) ⇒ Object

Hack for Class.name This method overwritten the default class method



49
50
51
# File 'lib/coderwall-ruby-api.rb', line 49

def name(username)
	self.new(username).name
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
# File 'lib/coderwall-ruby-api.rb', line 14

def [](key)
	return @user_data[key.to_s]
end