Class: Thimbl::Command
- Inherits:
-
Object
- Object
- Thimbl::Command
- Defined in:
- lib/thimbl/command.rb
Constant Summary collapse
- THIMBL_FOLDER =
File.( "~#{ENV['USER']}/.thimbl" )
Class Method Summary collapse
- .follow(nick = nil, address = nil, password = nil) ⇒ Object
- .post(text = nil, password = nil) ⇒ Object
- .print ⇒ Object
- .setup(*args) ⇒ Object
- .version ⇒ Object
Class Method Details
.follow(nick = nil, address = nil, password = nil) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/thimbl/command.rb', line 61 def self.follow( nick = nil, address = nil, password = nil ) if( nick.nil? || nick.empty? || address.nil? || address.empty? || password.nil? ) raise ArgumentError, "use: $ thimblr follow <nick> <address> <password>" end thimbl = get_actual thimbl.follow! nick, address, password end |
.post(text = nil, password = nil) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/thimbl/command.rb', line 52 def self.post( text = nil, password = nil) if( text.nil? || text.empty? || password.nil? ) raise ArgumentError, "use: $ thimblr post <message> <password>" end thimbl = get_actual thimbl.post! text, password end |
.print ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/thimbl/command.rb', line 21 def self.print thimbl = get_actual thimbl.fetch # user's messages = thimbl. # user's following's messages thimbl.following.each do |followed| thimbl = Thimbl::Base.new followed.address begin thimbl.fetch += thimbl. rescue Thimbl::NoPlanException puts "Error fetching #{followed.address} messages" end end = .sort { |a,b| a.time <=> b.time } result = "" .each do || result += .time.strftime( '%Y-%m-%d %H:%M:%S' ) result += " #{.address}" result += " > #{.text}" result += "\n" end return result end |
.setup(*args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/thimbl/command.rb', line 9 def self.setup( *args ) if( args.size != 1 ) raise ArgumentError, "use: $ thimblr setup <thimbl_user>" end if !File.exists? File.dirname( thimbl_folder ) FileUtils.mkdir_p File.dirname( thimbl_folder ) end save_actual args[0] end |
.version ⇒ Object
5 6 7 |
# File 'lib/thimbl/command.rb', line 5 def self.version "0.2.0" end |