Class: USaidWat::Client::BaseRedditor

Inherits:
Object
  • Object
show all
Defined in:
lib/usaidwat/client.rb

Direct Known Subclasses

Redditor, TestRedditor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ BaseRedditor

Returns a new instance of BaseRedditor.



17
18
19
# File 'lib/usaidwat/client.rb', line 17

def initialize(username)
  @username = username
end

Instance Attribute Details

#usernameObject (readonly)

Returns the value of attribute username.



15
16
17
# File 'lib/usaidwat/client.rb', line 15

def username
  @username
end

Instance Method Details

#ageObject



41
42
43
# File 'lib/usaidwat/client.rb', line 41

def age
  (Time.now - created_at).ago
end

#comment_karmaObject



33
34
35
# File 'lib/usaidwat/client.rb', line 33

def comment_karma
  about.comment_karma
end

#commentsObject



21
22
23
24
25
26
27
# File 'lib/usaidwat/client.rb', line 21

def comments
  user.comments(100)
rescue NoMethodError
  raise NoSuchUserError, username
rescue RuntimeError
  raise ReachabilityError
end

#created_atObject



37
38
39
# File 'lib/usaidwat/client.rb', line 37

def created_at
  about.created_utc
end


29
30
31
# File 'lib/usaidwat/client.rb', line 29

def link_karma
  about.link_karma
end

#postsObject



49
50
51
52
53
54
55
# File 'lib/usaidwat/client.rb', line 49

def posts
  user.posts
rescue NoMethodError
  raise NoSuchUserError, username
rescue RuntimeError
  raise ReachabilityError
end

#to_sObject



45
46
47
# File 'lib/usaidwat/client.rb', line 45

def to_s
  "#{username}"
end