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.
-
#create_new_badge(badge) ⇒ Object
create a new badge object.
-
#initialize ⇒ Builder
constructor
Instantiate class.
-
#parse_accounts(accounts) ⇒ Object
parse account information from data.
-
#parse_badges(badges) ⇒ 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
31 32 33 34 35 |
# File 'lib/coder_wally/builder.rb', line 31 def build(response) user = parse_user(response) CoderWall.new user end |
#create_new_badge(badge) ⇒ Object
create a new badge object
14 15 16 |
# File 'lib/coder_wally/builder.rb', line 14 def create_new_badge(badge) Badge.new(badge) end |
#parse_accounts(accounts) ⇒ Object
parse account information from data
19 20 21 |
# File 'lib/coder_wally/builder.rb', line 19 def parse_accounts(accounts) Account.new(accounts) if accounts end |
#parse_badges(badges) ⇒ Object
parse badges from data
9 10 11 |
# File 'lib/coder_wally/builder.rb', line 9 def parse_badges(badges) badges.map { |badge| create_new_badge(badge) } if badges end |
#parse_user(data) ⇒ Object
parse user information from data
24 25 26 27 28 |
# File 'lib/coder_wally/builder.rb', line 24 def parse_user(data) badges = parse_badges(data['badges']) accounts = parse_accounts(data['accounts']) User.new(data, badges, accounts) end |