Class: BashAPI
- Inherits:
-
Object
- Object
- BashAPI
- Defined in:
- lib/interface/bash_api.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
Instance Method Summary collapse
-
#initialize ⇒ BashAPI
constructor
A new instance of BashAPI.
- #process ⇒ Object
Constructor Details
#initialize ⇒ BashAPI
Returns a new instance of BashAPI.
63 64 65 66 67 68 69 |
# File 'lib/interface/bash_api.rb', line 63 def initialize @flagsToActions={ :d => proc{@entry.delete(@f.d)} , :g=>proc{puts @entry.get_content(@f.g).source}, :l=>proc{@entry.find_all_entries.each{|e| puts e.eid+' '+e.title}}, :c=>proc{post_request} } end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
61 62 63 |
# File 'lib/interface/bash_api.rb', line 61 def entry @entry end |
Instance Method Details
#process ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/interface/bash_api.rb', line 71 def process @f = ARGV.flags FileUtils.mkdir(ENV['HOME']+'/.snipplr') if !File.exist?(ENV['HOME']+'/.snipplr') begin key=(@f.key ? @f.key : (IO.read(ENV['HOME']+'/.snipplr/api_key')).chomp!) @entry=SnipplrEntry.new(key) rescue => e puts 'No snipplr API key found, make sure to initialize api_key file (under ~/.snipplr) or to pass in -key parameter' return end process_calls end |