Class: Redcli::Application
- Inherits:
-
Object
- Object
- Redcli::Application
- Defined in:
- lib/redcli/application.rb
Constant Summary collapse
- ROOT =
"http://www.reddit.com"- COLORS =
[:white, :yellow]
Instance Method Summary collapse
-
#initialize(subreddit:, stdout: STDOUT, stdin: STDIN) ⇒ Application
constructor
A new instance of Application.
- #link(link_index) ⇒ Object
- #links ⇒ Object
- #open_current_link ⇒ Object
- #run ⇒ Object
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
#link(link_index) ⇒ Object
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 |
#links ⇒ Object
26 27 28 29 30 |
# File 'lib/redcli/application.rb', line 26 def links display_links prompt_links_input act_on_input end |
#open_current_link ⇒ Object
39 40 41 42 |
# File 'lib/redcli/application.rb', line 39 def open_current_link url = @current_link["data"]["url"] `open #{url}` end |
#run ⇒ Object
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 |