Class: Rrant::Handler

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/rrant/handler.rb

Overview

Public: Initializes all the necessary objects and contains configuration methods.

Instance Method Summary collapse

Methods included from Helper

#bill, #files_path, #image_blank?

Constructor Details

#initializeHandler

Returns a new instance of Handler.



13
14
15
16
17
18
# File 'lib/rrant/handler.rb', line 13

def initialize
  @store       = Store.new
  @unseen      = false
  @show_images = false
  @bill        = false
end

Instance Method Details

#andObject



41
42
43
# File 'lib/rrant/handler.rb', line 41

def and
  self
end

#dos(min_amount = 10) ⇒ Object

Public: Fetches rants from remote API. Returns bill if amount is too high.

min_amount - Integer, how many rants we want to fetch.

Returns self.



34
35
36
37
38
39
# File 'lib/rrant/handler.rb', line 34

def dos(min_amount = 10)
  return @bill = true if min_amount > 80

  remote.save(min_amount)
  self
end

#raveObject

Public: Finds random rant or bill and initializes output with it.

Returns instance of Rrant::Output.



23
24
25
26
# File 'lib/rrant/handler.rb', line 23

def rave
  rant = @bill ? bill : local.unseen(@unseen).random
  Output.new(rant, @show_images)
end

#unseen(set = true) ⇒ Object



50
51
52
53
# File 'lib/rrant/handler.rb', line 50

def unseen(set = true)
  @unseen = set
  self
end

#with_images(set = true) ⇒ Object



45
46
47
48
# File 'lib/rrant/handler.rb', line 45

def with_images(set = true)
  @show_images = set
  self
end