Class: RPaste::NoPaste::ResultSet

Inherits:
ResultSet
  • Object
show all
Defined in:
lib/rpaste/nopaste/result_set.rb,
lib/rpaste/pastebin/result_set.rb

Instance Method Summary collapse

Methods inherited from ResultSet

#authors, #by_author, #clear, #each_by_author, #each_paste, #each_paste_by_author, #each_paste_on_date, #each_paste_with_name, #each_with_name, #initialize, #names, #paste, #pastes, #pastes_by_author, #pastes_on_date, #pastes_with, #pastes_with_name, #select, #with_name

Constructor Details

This class inherits a constructor from RPaste::ResultSet

Instance Method Details

#between_ages(start, stop) ⇒ Object

Selects the metadata with ages between start and stop.



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

def between_ages(start,stop)
  self.select { |data| data.ago.between?(start,stop) }
end

#between_dates(start, stop) ⇒ Object

Selects the metadata with dates in between start and stop.



32
33
34
# File 'lib/rpaste/nopaste/result_set.rb', line 32

def between_dates(start,stop)
  self.select { |data| data.date.between?(start,stop) }
end

#datesObject

Returns an Array containing the metadata dates.



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

def dates
  self.map { |data| data.date }
end

#descriptionsObject

Returns an Array containing the metadata descriptions.



25
26
27
# File 'lib/rpaste/nopaste/result_set.rb', line 25

def descriptions
  self.map { |data| data.description }
end

#each_between_ages(start, stop, &block) ⇒ Object

Iterates over the metadata with ages between start and stop, passing each to the given block.



19
20
21
# File 'lib/rpaste/pastebin/result_set.rb', line 19

def each_between_ages(start,stop,&block)
  between_ages(start,stop).each(&block)
end

#each_between_dates(start, stop, &block) ⇒ Object

Iterates over the metadata with dates falling in between start and stop, passing each to the given block.



70
71
72
# File 'lib/rpaste/nopaste/result_set.rb', line 70

def each_between_dates(start,stop,&block)
  between_dates(start,stop).each(&block)
end

#each_paste_between_ages(start, stop, &block) ⇒ Object

Iterates over the pastes with ages between start and stop, passing each to the given block.



34
35
36
# File 'lib/rpaste/pastebin/result_set.rb', line 34

def each_paste_between_ages(start,stop,&block)
  pastes_between_ages(start,stop).each(&block)
end

#each_paste_between_dates(start, stop, &block) ⇒ Object

Iterates over the pastes with dates falling in between start and stop, passing each to the given block.



151
152
153
# File 'lib/rpaste/nopaste/result_set.rb', line 151

def each_paste_between_dates(start,stop,&block)
  pastes_between_dates(start,stop).each(&block)
end

#each_paste_with_description(description, &block) ⇒ Object

Itereates over the pastes with the matching description, passing each to the given block.

results.each_paste_with_description('stack') do |paste|
  puts paste.text
end

results.each_paste_with_description(/(weird|odd)/) do |paste|
  puts paste.text
end


179
180
181
# File 'lib/rpaste/nopaste/result_set.rb', line 179

def each_paste_with_description(description,&block)
  pastes_with_syntax(description).each(&block)
end

#each_paste_with_syntax(syntax, &block) ⇒ Object

Iterates over the pastes with the matching syntax, passing each to the given block.

results.each_paste_with_syntax('Java') do |paste|
  puts paste.author
end


163
164
165
# File 'lib/rpaste/nopaste/result_set.rb', line 163

def each_paste_with_syntax(syntax,&block)
  pastes_with_syntax(syntax).each(&block)
end

#each_paste_with_text(text, &block) ⇒ Object

Iterates over the pastes with the matching text, passing each to the given block.

results.each_paste_with_text('$_GET') do |paste|
  puts paste.text
end

results.each_paste_with_text(/goto/) do |paste|
  puts paste.author
end


195
196
197
# File 'lib/rpaste/nopaste/result_set.rb', line 195

def each_paste_with_text(text,&block)
  pastes_with_text(text).each(&block)
end

#each_with_description(description, &block) ⇒ Object

Iterates over the metadata with the matching description, passing each to the given block.

results.each_with_description('fizz') do ||
  puts .author
end

results.each_with_description(/(fi|bu)zz/) do ||
  puts .syntax
end


98
99
100
# File 'lib/rpaste/nopaste/result_set.rb', line 98

def each_with_description(description,&block)
  with_description(description).each(&block)
end

#each_with_syntax(syntax, &block) ⇒ Object

Iterates over the metadata with the matching syntax, passing each to the given block.

results.each_with_syntax('ASM') do ||
  puts .description
end


82
83
84
# File 'lib/rpaste/nopaste/result_set.rb', line 82

def each_with_syntax(syntax,&block)
  with_syntax(syntax).each(&block)
end

#pastes_between_ages(start, stop) ⇒ Object

Returns the pastes with ages between start and stop.



26
27
28
# File 'lib/rpaste/pastebin/result_set.rb', line 26

def pastes_between_ages(start,stop)
  pastes_with { |data| data.age.between?(start,stop) }
end

#pastes_between_dates(start, stop) ⇒ Object

Returns the pastes with dates falling in between start and stop.



106
107
108
# File 'lib/rpaste/nopaste/result_set.rb', line 106

def pastes_between_dates(start,stop)
  pastes_with { |data| data.date.between?(start,stop) }
end

#pastes_with_description(description) ⇒ Object

Returns the pastes with the matching description.

results.pastes_with_description('error')
results.pastes_with_description(/\d+(\.\d+)+/)


125
126
127
128
129
130
131
# File 'lib/rpaste/nopaste/result_set.rb', line 125

def pastes_with_description(description)
  if description.kind_of?(Regexp)
    return pastes_with { |data| data.description =~ description }
  else
    return pastes_with { |data| data.description.include?(description) }
  end
end

#pastes_with_syntax(syntax) ⇒ Object

Returns the pastes with the matching syntax.

results.pastes_with_syntax('Javascript')


115
116
117
# File 'lib/rpaste/nopaste/result_set.rb', line 115

def pastes_with_syntax(syntax)
  pastes_with { |data| data.syntax == syntax }
end

#pastes_with_text(text) ⇒ Object

Returns the pastes with the matching text.

results.pastes_with_text('strcpy')
results.pastes_with_text(/printf\([^\",]+,/)


139
140
141
142
143
144
145
# File 'lib/rpaste/nopaste/result_set.rb', line 139

def pastes_with_text(text)
  if text.kind_of?(Regexp)
    return pastes_with { |data| data.text =~ text }
  else
    return pastes_with { |data| data.text.include?(text) }
  end
end

#search(desc) ⇒ Object

A symonym for with_description.



62
63
64
# File 'lib/rpaste/nopaste/result_set.rb', line 62

def search(desc)
  with_description(desc)
end

#syntaxesObject

Returns an Array containing the metadata syntaxes.



18
19
20
# File 'lib/rpaste/nopaste/result_set.rb', line 18

def syntaxes
  self.map { |data| data.syntax }
end

#with_description(description) ⇒ Object

Selects the metadata containing description.

results.with_description('hello world')
results.with_description(/(form|reg)/)


51
52
53
54
55
56
57
# File 'lib/rpaste/nopaste/result_set.rb', line 51

def with_description(description)
  if description.kind_of?(Regexp)
    return self.select { |data| data.description =~ description }
  else
    return self.select { |data| data.description.include?(description) }
  end
end

#with_syntax(syntax) ⇒ Object

Selects the metadata with the specified syntax.

results.with_syntax('PHP')


41
42
43
# File 'lib/rpaste/nopaste/result_set.rb', line 41

def with_syntax(syntax)
  self.select { |data| data.syntax == syntax }
end