Class: Redcli::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/redcli/application.rb

Constant Summary collapse

ROOT =
"http://www.reddit.com"
COLORS =
[:white, :yellow]

Instance Method Summary collapse

Constructor Details

#initialize(subreddit:, stdout: STDOUT, stdin: STDIN) ⇒ Application

Returns a new instance of Application.



11
12
13
14
15
# File 'lib/redcli/application.rb', line 11

def initialize(subreddit:, stdout:STDOUT, stdin: STDIN)
  @subreddit = subreddit
  @stdout = stdout
  @stdin = stdin
end

Instance Method Details



32
33
34
35
36
37
# File 'lib/redcli/application.rb', line 32

def link(link_index)
  @current_link = @links[link_index]
  display_topic(link_index)
  prompt_link_input
  act_on_input
end


26
27
28
29
30
# File 'lib/redcli/application.rb', line 26

def links
  display_links
  prompt_links_input
  act_on_input
end


39
40
41
42
# File 'lib/redcli/application.rb', line 39

def open_current_link
  url = @current_link["data"]["url"]
  `open #{url}`
end

#runObject



17
18
19
20
21
22
23
24
# File 'lib/redcli/application.rb', line 17

def run
  @links = get_links
  if @links
    links
  else
    signal_failure
  end
end