Class: CodewarsCli::User

Inherits:
Object
  • Object
show all
Includes:
GenericHelpers
Defined in:
lib/codewars_cli/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GenericHelpers

#check_for_api_key, #client, #error, #extend_object, included, #info, #presenter

Constructor Details

#initialize(username_or_id) ⇒ User

Returns a new instance of User.



10
11
12
# File 'lib/codewars_cli/user.rb', line 10

def initialize(username_or_id)
  @username_or_id = username_or_id
end

Instance Attribute Details

#username_or_idObject (readonly)

Returns the value of attribute username_or_id.



9
10
11
# File 'lib/codewars_cli/user.rb', line 9

def username_or_id
  @username_or_id
end

Class Method Details

.fetch(username_or_id) ⇒ Object



4
5
6
7
# File 'lib/codewars_cli/user.rb', line 4

def self.fetch(username_or_id)
  check_for_api_key
  new(username_or_id)
end

Instance Method Details

#get_userObject



14
15
16
# File 'lib/codewars_cli/user.rb', line 14

def get_user
  client.user(username_or_id: username_or_id)
end


18
19
20
# File 'lib/codewars_cli/user.rb', line 18

def print_description
  presenter.(get_user)
end