Class: Twterm::Friendship
- Inherits:
-
Object
- Object
- Twterm::Friendship
- Defined in:
- lib/twterm/friendship.rb
Constant Summary collapse
- STATUSES =
%i( blocking following following_requested muting ).freeze
- @@instances =
[]
- @@user_ids =
Set.new
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
- .already_looked_up?(user_id) ⇒ Boolean
- .block(from, to) ⇒ Object
- .blocking?(from, to) ⇒ Boolean
- .cancel_follow_request(from, to) ⇒ Object
- .follow(from, to) ⇒ Object
- .following?(from, to) ⇒ Boolean
- .following_not_requested(from, to) ⇒ Object
- .following_requested(from, to) ⇒ Object
- .following_requested?(from, to) ⇒ Boolean
- .looked_up!(user_id) ⇒ Object
- .mute(from, to) ⇒ Object
- .muting?(from, to) ⇒ Boolean
- .unblock(from, to) ⇒ Object
- .unfollow(from, to) ⇒ Object
- .unmute(from, to) ⇒ Object
Instance Method Summary collapse
- #blocking? ⇒ Boolean
- #following? ⇒ Boolean
- #following_requested? ⇒ Boolean
-
#initialize(status, from, to) ⇒ Friendship
constructor
A new instance of Friendship.
- #muting? ⇒ Boolean
Constructor Details
#initialize(status, from, to) ⇒ Friendship
Returns a new instance of Friendship.
15 16 17 18 19 20 21 |
# File 'lib/twterm/friendship.rb', line 15 def initialize(status, from, to) fail ArgumentError, '' unless STATUSES.include? status @status, @from, @to = status, from, to @@instances << self end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
10 11 12 |
# File 'lib/twterm/friendship.rb', line 10 def from @from end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/twterm/friendship.rb', line 10 def status @status end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
10 11 12 |
# File 'lib/twterm/friendship.rb', line 10 def to @to end |
Class Method Details
.already_looked_up?(user_id) ⇒ Boolean
39 40 41 |
# File 'lib/twterm/friendship.rb', line 39 def self.already_looked_up?(user_id) @@user_ids.include?(user_id) end |
.block(from, to) ⇒ Object
43 44 45 |
# File 'lib/twterm/friendship.rb', line 43 def self.block(from, to) new(:blocking, from, to) end |
.blocking?(from, to) ⇒ Boolean
47 48 49 |
# File 'lib/twterm/friendship.rb', line 47 def self.blocking?(from, to) !find(:blocking, from, to).nil? end |
.cancel_follow_request(from, to) ⇒ Object
51 52 53 |
# File 'lib/twterm/friendship.rb', line 51 def self.cancel_follow_request(from, to) new(:following_requested, from, to) end |
.follow(from, to) ⇒ Object
67 68 69 |
# File 'lib/twterm/friendship.rb', line 67 def self.follow(from, to) new(:following, from, to) end |
.following?(from, to) ⇒ Boolean
71 72 73 |
# File 'lib/twterm/friendship.rb', line 71 def self.following?(from, to) !find(:following, from, to).nil? end |
.following_not_requested(from, to) ⇒ Object
75 76 77 |
# File 'lib/twterm/friendship.rb', line 75 def self.following_not_requested(from, to) delete(:following_requested, from, to) end |
.following_requested(from, to) ⇒ Object
79 80 81 |
# File 'lib/twterm/friendship.rb', line 79 def self.following_requested(from, to) new(:following_requested, from, to) end |
.following_requested?(from, to) ⇒ Boolean
83 84 85 |
# File 'lib/twterm/friendship.rb', line 83 def self.following_requested?(from, to) !find(:following_requested, from, to).nil? end |
.looked_up!(user_id) ⇒ Object
87 88 89 90 |
# File 'lib/twterm/friendship.rb', line 87 def self.looked_up!(user_id) @@user_ids << user_id user_id end |
.mute(from, to) ⇒ Object
92 93 94 |
# File 'lib/twterm/friendship.rb', line 92 def self.mute(from, to) new(:muting, from, to) end |
.muting?(from, to) ⇒ Boolean
96 97 98 |
# File 'lib/twterm/friendship.rb', line 96 def self.muting?(from, to) !find(:muting, from, to).nil? end |
.unblock(from, to) ⇒ Object
106 107 108 |
# File 'lib/twterm/friendship.rb', line 106 def self.unblock(from, to) delete(:blocking, from, to) end |
.unfollow(from, to) ⇒ Object
110 111 112 |
# File 'lib/twterm/friendship.rb', line 110 def self.unfollow(from, to) delete(:following, from, to) end |
.unmute(from, to) ⇒ Object
114 115 116 |
# File 'lib/twterm/friendship.rb', line 114 def self.unmute(from, to) delete(:muting, from, to) end |
Instance Method Details
#blocking? ⇒ Boolean
23 24 25 |
# File 'lib/twterm/friendship.rb', line 23 def blocking? status?(:blocking) end |
#following? ⇒ Boolean
27 28 29 |
# File 'lib/twterm/friendship.rb', line 27 def following? status?(:following) end |
#following_requested? ⇒ Boolean
31 32 33 |
# File 'lib/twterm/friendship.rb', line 31 def following_requested? status?(:following_requested) end |
#muting? ⇒ Boolean
35 36 37 |
# File 'lib/twterm/friendship.rb', line 35 def muting? status?(:muting) end |