Class: Pbl::CLI
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize ⇒ CLI
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pbl/cli.rb', line 31 def initialize config = Pit.get(:pinboard, require: { username: "your_account_in_pinboard", password: "your_password_in_pinboard" } ) @pinboard = Pinboard::Client.new( username: config[:username], password: config[:password] ) @argv = ARGV || [] end |
Class Method Details
.run ⇒ Object
47 48 49 |
# File 'lib/pbl/cli.rb', line 47 def self.run self.new.run end |
Instance Method Details
#run ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pbl/cli.rb', line 51 def run page unless $test_env if @argv.empty? @pinboard.posts(:results => 150).each do |post| puts "[%s] %s %s" % [post[:time].strftime("%Y/%m/%d").cyan, post[:description].cut, post[0].green] end else @pinboard.posts(:tag => @argv.join(',')).each do |post| puts "[%s] %s %s" % [post[:time].strftime("%Y/%m/%d").cyan, post[:description].cut, post[0].green] end end end |