Class: Pastenum::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/pastenum/json.rb

Instance Method Summary collapse

Constructor Details

#initialize(dork, sites) ⇒ JSON

Returns a new instance of JSON.



4
5
6
7
8
9
# File 'lib/pastenum/json.rb', line 4

def initialize(dork, sites)
  @data =  [{:search => dork}]
  sites.each do |site|
    @data << {site.vendor => site.results}
  end 
end

Instance Method Details

#to_fileObject



15
16
17
18
19
20
21
# File 'lib/pastenum/json.rb', line 15

def to_file  
  file = File.open('report.json', 'w') 
  file.write(data.to_json)
  file.close
  
  return @data
end

#to_sObject



11
12
13
# File 'lib/pastenum/json.rb', line 11

def to_s
  return @data
end