Class: RPaste::Paste

Inherits:
Object
  • Object
show all
Defined in:
lib/rpaste/paste.rb

Direct Known Subclasses

NoPaste::Paste

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, author = nil, date = nil, syntax = nil, text = nil, &block) ⇒ Paste

Creates a new Paste object with the optional name, author, date, syntax and text. If a block is given, then it will be passed the newly created Paste object.



24
25
26
27
28
29
30
31
32
# File 'lib/rpaste/paste.rb', line 24

def initialize(name=nil,author=nil,date=nil,syntax=nil,text=nil,&block)
  @name = name
  @author = author
  @date = Time.parse(date) if date
  @syntax = syntax
  @text = text

  block.call(self) if block
end

Instance Attribute Details

#authorObject

Author of the entry



8
9
10
# File 'lib/rpaste/paste.rb', line 8

def author
  @author
end

#dateObject

Date of the entry



11
12
13
# File 'lib/rpaste/paste.rb', line 11

def date
  @date
end

#nameObject

Name of the entry



5
6
7
# File 'lib/rpaste/paste.rb', line 5

def name
  @name
end

#syntaxObject

Syntax of the entry text



14
15
16
# File 'lib/rpaste/paste.rb', line 14

def syntax
  @syntax
end

#textObject

Text of the entry



17
18
19
# File 'lib/rpaste/paste.rb', line 17

def text
  @text
end

Instance Method Details

#to_aObject

Returns an array containing the text lines of the paste.



44
45
46
# File 'lib/rpaste/paste.rb', line 44

def to_a
  self.to_s.split
end

#to_sObject

Returns a string containing the text of the paste.



37
38
39
# File 'lib/rpaste/paste.rb', line 37

def to_s
  @text.to_s
end