Class Pastis::Paste
In: lib/pastis/paste.rb
Parent: Object

Represents a paste, shoudn‘t be created by hand

Methods

body   new   preview   raw_url   time   to_s  

Attributes

url  [R] 

Public Class methods

[Source]

# File lib/pastis/paste.rb, line 4
    def initialize(attributes)
      %w(url body time preview).each do |attribute|
        instance_variable_set("@#{attribute}", attributes[attribute.intern])
      end
    end

Public Instance methods

Body of the paste

[Source]

# File lib/pastis/paste.rb, line 28
    def body
      @body ||= get(raw_url)
    end

5 first lines of the paste

[Source]

# File lib/pastis/paste.rb, line 18
    def preview
      @preview ||= body.split("\n")[0, 6].join("\n")
    end

Url of the raw paste

[Source]

# File lib/pastis/paste.rb, line 13
    def raw_url
      "#{url}.txt"
    end

Creation time

[Source]

# File lib/pastis/paste.rb, line 23
    def time
      @time ||= Time.parse(Hpricot(get(url)).at("#paste_date").innerText)
    end
to_s()

Alias for body

[Validate]