Class: Hackershout::Provider::Base

Inherits:
Object
  • Object
show all
Includes:
Output
Defined in:
lib/hackershout/provider/base.rb

Direct Known Subclasses

Hackernews, Reddit, Rubyflow

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Output

#blank, #print

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hackershout/provider/base.rb', line 13

def initialize(options = {})
  @name = self.class.name.split("::").last
  @url = options[:url] << "&utm_medium=#{@name.downcase}"
  @title = options[:title]
  @tags = options[:tags]
  @message = options[:message]

  creds = YAML.load(File.read(File.join(File.expand_path('~'), '.hackershoutrc')))[@name.downcase]
  raise "Can't find credentials on ~/.hackershoutrc for #{@name}" unless creds

  @login = creds["login"]
  @password = creds["password"]
  @agent = Mechanize.new
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



9
10
11
# File 'lib/hackershout/provider/base.rb', line 9

def agent
  @agent
end

Instance Method Details

#postObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/hackershout/provider/base.rb', line 34

def post
  raise NotImplementedError
end

#publishObject



28
29
30
31
32
# File 'lib/hackershout/provider/base.rb', line 28

def publish
  print "Posting to #{@name}..."
  post unless ENV['NOSEND']
  print "Posted to #{@name}!"
end