Class: Nwcopy::Gist
- Inherits:
-
Object
- Object
- Nwcopy::Gist
- Defined in:
- lib/nwcopy/gist.rb
Class Attribute Summary collapse
-
.gist ⇒ Object
writeonly
Sets the attribute gist.
Class Method Summary collapse
- .available? ⇒ Boolean
- .copy(io) ⇒ Object
- .paste(ignored = nil) ⇒ Object
- .time ⇒ Object
- .unavailable_message ⇒ Object
Class Attribute Details
.gist=(value) ⇒ Object
Sets the attribute gist
9 10 11 |
# File 'lib/nwcopy/gist.rb', line 9 def gist=(value) @gist = value end |
Class Method Details
.available? ⇒ Boolean
16 17 18 |
# File 'lib/nwcopy/gist.rb', line 16 def self.available? !gist.send(:auth).empty? end |
.copy(io) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/nwcopy/gist.rb', line 24 def self.copy io clipboard = io.read digest = Digest::SHA1.hexdigest clipboard filename = io.respond_to?(:filename) ? io.filename : digest gist.write [{:filename => filename, :input => clipboard}], false end |
.paste(ignored = nil) ⇒ Object
31 32 33 |
# File 'lib/nwcopy/gist.rb', line 31 def self.paste ignored = nil gist.read latest_gist["repo"] end |
.time ⇒ Object
20 21 22 |
# File 'lib/nwcopy/gist.rb', line 20 def self.time Time.parse(latest_gist["created_at"]) end |
.unavailable_message ⇒ Object
12 13 14 |
# File 'lib/nwcopy/gist.rb', line 12 def self. "Github is not configured. Cannot use Gist." end |