Class: CoderWally::Builder
- Inherits:
-
Object
- Object
- CoderWally::Builder
- Defined in:
- lib/coder_wally/builder.rb
Overview
Builds the CoderWall object from the response
Instance Method Summary collapse
-
#build(response) ⇒ Object
build CoderWall object from API response.
-
#initialize ⇒ Builder
constructor
Instantiate class.
-
#parse_accounts(data) ⇒ Object
parse account information from data.
-
#parse_badges(data) ⇒ Object
parse badges from data.
-
#parse_user(data) ⇒ Object
parse user information from data.
Constructor Details
#initialize ⇒ Builder
Instantiate class
5 6 |
# File 'lib/coder_wally/builder.rb', line 5 def initialize end |
Instance Method Details
#build(response) ⇒ Object
build CoderWall object from API response
25 26 27 28 29 30 31 |
# File 'lib/coder_wally/builder.rb', line 25 def build(response) badges = parse_badges(response) accounts = parse_accounts(response) user = parse_user(response) CoderWall.new badges, user, accounts end |
#parse_accounts(data) ⇒ Object
parse account information from data
14 15 16 |
# File 'lib/coder_wally/builder.rb', line 14 def parse_accounts(data) Account.new(data['accounts']) if data['accounts'] end |
#parse_badges(data) ⇒ Object
parse badges from data
9 10 11 |
# File 'lib/coder_wally/builder.rb', line 9 def parse_badges(data) data['badges'].map { |badge| Badge.new(badge) } if data['badges'] end |
#parse_user(data) ⇒ Object
parse user information from data
19 20 21 22 |
# File 'lib/coder_wally/builder.rb', line 19 def parse_user(data) User.new(data['name'], data['username'], data['location'], data['team'], data['endorsements']) end |