Class: Nwcopy::Gist

Inherits:
Object
  • Object
show all
Defined in:
lib/nwcopy/gist.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.gist=(value) ⇒ Object

Sets the attribute gist

Parameters:

  • value

    the value to set the attribute gist to.



9
10
11
# File 'lib/nwcopy/gist.rb', line 9

def gist=(value)
  @gist = value
end

Class Method Details

.available?Boolean

Returns:

  • (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

.timeObject



20
21
22
# File 'lib/nwcopy/gist.rb', line 20

def self.time
  Time.parse(latest_gist["created_at"])
end

.unavailable_messageObject



12
13
14
# File 'lib/nwcopy/gist.rb', line 12

def self.unavailable_message
  "Github is not configured. Cannot use Gist."
end