Class: ReplTalk::User

Inherits:
Object
  • Object
show all
Defined in:
lib/repltalk/structures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, user) ⇒ User

Returns a new instance of User.



481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/repltalk/structures.rb', line 481

def initialize(client, user)
	return nil if user == nil
	@client = client

	@id = user["id"]
	@username = user["username"]
	@name = user["fullName"]
	@pfp = user["image"]
	@bio = user["bio"]
	@is_hacker = user["isHacker"]
	@timestamp = user["timeCreated"]
	@roles = user["roles"].map { |role| Role.new(role) }
	@languages = user["languages"].map { |lang| Language.new(lang) }
end

Instance Attribute Details

#bioObject (readonly)

Returns the value of attribute bio.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def bio
  @bio
end

#cyclesObject (readonly)

Returns the value of attribute cycles.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def cycles
  @cycles
end

#idObject (readonly)

Returns the value of attribute id.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def id
  @id
end

#is_hackerObject (readonly)

Returns the value of attribute is_hacker.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def is_hacker
  @is_hacker
end

#languagesObject (readonly)

Returns the value of attribute languages.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def languages
  @languages
end

#nameObject (readonly)

Returns the value of attribute name.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def name
  @name
end

#pfpObject (readonly)

Returns the value of attribute pfp.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def pfp
  @pfp
end

#rolesObject (readonly)

Returns the value of attribute roles.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def roles
  @roles
end

#subscriptionObject (readonly)

Returns the value of attribute subscription.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def subscription
  @subscription
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def timestamp
  @timestamp
end

#usernameObject (readonly)

Returns the value of attribute username.



479
480
481
# File 'lib/repltalk/structures.rb', line 479

def username
  @username
end

Instance Method Details

#get_comments(order: "new", count: nil, after: nil) ⇒ Object



508
509
510
511
512
513
514
515
516
517
518
# File 'lib/repltalk/structures.rb', line 508

def get_comments(order: "new", count: nil, after: nil)
	c = @client.graphql(
		"user",
		GQL::Queries::GET_USER_COMMENTS,
		username: @username,
		order: order,
		count: count,
		after: after
	)
	c["user"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
end

#get_posts(order: "new", count: nil, after: nil) ⇒ Object



496
497
498
499
500
501
502
503
504
505
506
# File 'lib/repltalk/structures.rb', line 496

def get_posts(order: "new", count: nil, after: nil)
	p = @client.graphql(
		"user",
		GQL::Queries::GET_USER_POSTS,
		username: @username,
		order: order,
		count: count,
		after: after
	)
	p["user"]["posts"]["items"].map { |post| Post.new(@client, post) }
end

#get_repls(count: nil, order: nil, direction: nil, before: nil, after: nil, pinnedReplsFirst: nil, showUnnamed: nil) ⇒ Object



520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/repltalk/structures.rb', line 520

def get_repls(count: nil, order: nil, direction: nil, before: nil, after: nil, pinnedReplsFirst: nil, showUnnamed: nil)
	r = @client.graphql(
		"user",
		GQL::Queries::GET_USER_REPLS,
		username: @username,
		order: order,
		count: count,
		direction: direction,
		before: before,
		after: after,
		pinnedReplsFirst: pinnedReplsFirst,
		showUnnamed: showUnnamed
	)
	r["user"]["publicRepls"]["items"].map { |repl| Repl.new(@client, repl) }
end

#to_sObject



536
537
538
# File 'lib/repltalk/structures.rb', line 536

def to_s
	@username
end