Class: Myun2::TwitterShell::Ls
- Inherits:
-
Object
- Object
- Myun2::TwitterShell::Ls
- Defined in:
- lib/myun2/twitter_shell/ls.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #format(tweet, *params) ⇒ Object
- #home_timeline ⇒ Object
-
#initialize(client, *params) ⇒ Ls
constructor
A new instance of Ls.
- #mentions_timeline ⇒ Object
Constructor Details
#initialize(client, *params) ⇒ Ls
Returns a new instance of Ls.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/myun2/twitter_shell/ls.rb', line 8 def initialize(client, *params) @client = client if params && params.length > 0 case when params[0] == '-m' || params[0] == 'mention' || params[0] == 'mentions' timeline = mentions_timeline params.shift end end timeline ||= home_timeline timeline.each do |t| puts format(t, *params) end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/myun2/twitter_shell/ls.rb', line 6 def client @client end |
Instance Method Details
#format(tweet, *params) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/myun2/twitter_shell/ls.rb', line 33 def format(tweet, *params) u = tweet['user'] user_name = u['name'] screen_name = u['screen_name'] text = tweet['text'] if params && params.length > 0 && params[0][0] == '-' && params[0].include?('l') datetime = tweet['created_at'] "#{datetime} <#{screen_name}:#{user_name}>: #{text}" else "<#{user_name}>: #{text[0..30]}" end end |
#home_timeline ⇒ Object
29 30 31 |
# File 'lib/myun2/twitter_shell/ls.rb', line 29 def home_timeline client.home_timeline end |
#mentions_timeline ⇒ Object
25 26 27 |
# File 'lib/myun2/twitter_shell/ls.rb', line 25 def mentions_timeline client.mentions end |