Module: Termtter::Plugins::ListSwitch
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#list_name ⇒ Object
readonly
Returns the value of attribute list_name.
-
#list_user_id ⇒ Object
readonly
Returns the value of attribute list_user_id.
-
#list_user_name ⇒ Object
readonly
Returns the value of attribute list_user_name.
Instance Method Summary collapse
- #call_rubytter(rubytter_proxy, method, *args, &block) ⇒ Object
- #list_switch(full_name) ⇒ Object
- #restore ⇒ Object
- #split_list_name(list_name) ⇒ Object
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
32 33 34 |
# File 'lib/plugins/list_switch.rb', line 32 def active @active end |
#list_name ⇒ Object (readonly)
Returns the value of attribute list_name.
32 33 34 |
# File 'lib/plugins/list_switch.rb', line 32 def list_name @list_name end |
#list_user_id ⇒ Object (readonly)
Returns the value of attribute list_user_id.
32 33 34 |
# File 'lib/plugins/list_switch.rb', line 32 def list_user_id @list_user_id end |
#list_user_name ⇒ Object (readonly)
Returns the value of attribute list_user_name.
32 33 34 |
# File 'lib/plugins/list_switch.rb', line 32 def list_user_name @list_user_name end |
Instance Method Details
#call_rubytter(rubytter_proxy, method, *args, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/plugins/list_switch.rb', line 34 def call_rubytter(rubytter_proxy, method, *args, &block) if active case method when :home_timeline # => list_statuses(user_name, slug, options) method, args = :list_statuses, [list_user_name, list_name, *args] when :follow # => add_member_to_list(slug, user.id) method, args = :add_member_to_list, [list_name, *args] when :leave # => remove_member_from_list(slug, user.id) method, args = :remove_member_from_list, [list_name, *args] end end rubytter_proxy.call_rubytter_without_list_switch(method, *args, &block) end |
#list_switch(full_name) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/plugins/list_switch.rb', line 51 def list_switch(full_name) @active = true @list_user_name, @list_name = split_list_name(full_name) user = Termtter::API.twitter.cached_user(list_user_name) || Termtter::API.twitter.user(list_user_name) @list_user_id = user.id # TODO: やっつけなのでちゃんとやる config.prompt = full_name + '> ' end |
#restore ⇒ Object
61 62 63 64 65 |
# File 'lib/plugins/list_switch.rb', line 61 def restore @active = false # TODO: やっつけなのでちゃんとやる config.prompt = '> ' end |
#split_list_name(list_name) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/plugins/list_switch.rb', line 67 def split_list_name(list_name) if /([^\/]+)\/([^\/]+)/ =~ list_name [Termtter::Client.normalize_as_user_name($1), $2] else [config.user_name, $2] end end |