Class: Myun2::TwitterShell::Shell

Inherits:
ShellBase
  • Object
show all
Defined in:
lib/myun2/twitter_shell/shell.rb

Direct Known Subclasses

Twsh

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*params) ⇒ Shell

Returns a new instance of Shell.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/myun2/twitter_shell/shell.rb', line 13

def initialize(*params)
  if @profile = Profile.load
    @client = Client.new(@profile.data)
    if params && params.length > 0
      return self.send(*params)
    end
  else
    puts "Please first login"
  end

  version
  super
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/myun2/twitter_shell/shell.rb', line 11

def client
  @client
end

Instance Method Details

#login(*params) ⇒ Object



60
61
62
63
64
65
# File 'lib/myun2/twitter_shell/shell.rb', line 60

def (*params)
  Login.new(*params)

  @profile = Profile.load
  @client = Client.new(@profile.data)
end

#ls(*params) ⇒ Object



36
37
38
# File 'lib/myun2/twitter_shell/shell.rb', line 36

def ls(*params)
  Ls.new(client, *params)
end

#promptObject



56
57
58
# File 'lib/myun2/twitter_shell/shell.rb', line 56

def prompt
  "twsh:$ "
end

#tail(*params) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/myun2/twitter_shell/shell.rb', line 40

def tail(*params)
  #ls(*params)
  puts "Waiting for timelime..."
  if params[0] == '&'
    @tail_thread = Thread.start do
      Tail.new(@profile.data, *params)
    end
  else
    Tail.new(@profile.data, *params)
  end
end

#tweet(*params) ⇒ Object Also known as: p, t, post, update



27
28
29
30
# File 'lib/myun2/twitter_shell/shell.rb', line 27

def tweet(*params)
  client.update params.join(" ")
  puts "Post was successfully."
end

#versionObject



52
53
54
# File 'lib/myun2/twitter_shell/shell.rb', line 52

def version
  puts "twsh #{VERSION}"
end