Class: ReplTalk::User
- Inherits:
-
Object
- Object
- ReplTalk::User
- Defined in:
- lib/repltalk/structures.rb
Instance Attribute Summary collapse
-
#bio ⇒ Object
readonly
Returns the value of attribute bio.
-
#cycles ⇒ Object
readonly
Returns the value of attribute cycles.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_hacker ⇒ Object
readonly
Returns the value of attribute is_hacker.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pfp ⇒ Object
readonly
Returns the value of attribute pfp.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#subscription ⇒ Object
readonly
Returns the value of attribute subscription.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #get_comments(order: "new", count: nil, after: nil) ⇒ Object
- #get_posts(order: "new", count: nil, after: nil) ⇒ Object
- #get_repls(count: nil, order: nil, direction: nil, before: nil, after: nil, pinnedReplsFirst: nil, showUnnamed: nil) ⇒ Object
-
#initialize(client, user) ⇒ User
constructor
A new instance of User.
- #to_s ⇒ Object
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
#bio ⇒ Object (readonly)
Returns the value of attribute bio.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def bio @bio end |
#cycles ⇒ Object (readonly)
Returns the value of attribute cycles.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def cycles @cycles end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def id @id end |
#is_hacker ⇒ Object (readonly)
Returns the value of attribute is_hacker.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def is_hacker @is_hacker end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def languages @languages end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def name @name end |
#pfp ⇒ Object (readonly)
Returns the value of attribute pfp.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def pfp @pfp end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def roles @roles end |
#subscription ⇒ Object (readonly)
Returns the value of attribute subscription.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def subscription @subscription end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
479 480 481 |
# File 'lib/repltalk/structures.rb', line 479 def @timestamp end |
#username ⇒ Object (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_s ⇒ Object
536 537 538 |
# File 'lib/repltalk/structures.rb', line 536 def to_s @username end |