Class: Gistr
- Inherits:
-
Object
- Object
- Gistr
- Defined in:
- lib/gistr.rb
Instance Method Summary collapse
- #gist_code ⇒ Object
-
#initialize(gist_id) ⇒ Gistr
constructor
A new instance of Gistr.
- #post(email, password, title, blog) ⇒ Object
Constructor Details
#initialize(gist_id) ⇒ Gistr
Returns a new instance of Gistr.
5 6 7 |
# File 'lib/gistr.rb', line 5 def initialize(gist_id) @gist_id = gist_id end |
Instance Method Details
#gist_code ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gistr.rb', line 13 def gist_code return @gist_code if @gist_code # Use the secret .pibb format code = open("http://gist.github.com/#{@gist_id}.pibb").read # Remove the <pre> tag # # Tumblr wrap lines at of HTML at times and having the additional # whitespace in a <pre> is very undesirable. h = Hpricot(code) h.search('pre').each do |pre| pre.swap(pre.inner_html) end @gist_code = h.to_html end |
#post(email, password, title, blog) ⇒ Object
9 10 11 |
# File 'lib/gistr.rb', line 9 def post(email, password, title, blog) post_to_tumblr(email, password, title, blog, gist_code) end |